Today we can use Javascript in quite a number of places on a Notes form, as well as in views. But the Javascript is only able to access the UI. You can also not create agents using Javascript.
What I would like to see is a Javascript API/extension that would expose all the UI and backend classes to Javascript. This would allow a Notes application to be created or maintained by anyone knowing Javascript, broadening the appeal of the platform. Especially with Nomad for Web, I can see an increase in the interest for Notes client applications vs web applications.
To give you an idea of what the Javascript potentially could look like, here is some code. It has been heavily influenced by SuiteScript 2.0, the Javascript-based language used in Oracle's NetSuite ERP system.
define(['N/notesSession', 'N/notesUIWorkspace'],
function(session, workspace) {
function myBeforeQuerySave() {
let uiDoc = workspace.currentDocument;
let firstName = uiDoc.fieldGetText('FirstName');
let lastName = uiDoc.fieldGetText('LastName');
if (firstName=='' || lastname=='') {
alert("First name and last name needs to be entered.");
return false; // Prevents document from being saved
}
}
function afterDocIsSaved(source) {
let firstName = source.fieldGetText('FirstName');
let db = session.currentDatabase;
let lookupView = db.getView('by First Name');
let col = lookupView.getAllDocumentsByKey(firstName);
let lastnames = [];
for (let i=0; i<col.count; i++) {
let lastName = col.document.getItemValue("LastName")[0];
lastnames.push(lastName); // Add last name to array
}
let thisUNID = source.document.universalId;
let savedDoc = db.getDocumentByUNID(thisUNID);
savedDoc.replaceItemValue("LastNameList", lastnames);
savedDoc.save();
}
// Expose the functions above as Notes events
return {
beforeQuerySave: myBeforeQuerySave,
postQuerySave: afterDocIsSaved
}
}
);