SuiteScript is a JavaScript-based API which allows the developers to extend NetSuite features.
SuiteScript 2.0 is completly based on modules.
A module consists of a block of code to implement a particular functionality,
that can be invoked in the way how function or method is invoked.
// SuiteScript 1.0 //SuiteScript 2.0
*******************************************************
nlapiCreateRecord
nlapiGetFieldValue
nlapiSetFieldValue "N/record" Module
nlapiSubmitRecord
nlapiDeleteRecord
------------------------------------------------------
nlapiSearchRecord
nlapiSearchFilter "N/search" Module
nlapiSearchColumn
------------------------------------------------------
nlapiCreateFile
nlapiDeleteFile "N/file" Module
------------------------------------------------------
In Suite Script 1.0 there is no concept of module. All the APIs will
get loaded for every single script globally, whether you actually utilize the APIs or not in your Script.
Check out the above image.
Now SuiteScript 1.0 API functions are broken into different NetSuite modules [ record, https, search, currentRecord, etc.. ] So when you write a script,
you can include the specific modules which you gonna use.which prevents the scripts from loading more number of functionality which we are not going to utilize.
//JSDoc comment : Helps in finding out version and SuiteScript type.
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define([], function () {
function sampleSuiteScript(context) {
alert("sample SuiteScript 2.0");
}
return {
pageInit: sampleSuiteScript
};
});
/**
@NApiVersion 2.x
@NScriptType ClientScript
*/
define(["N/ui/message"], function (message) {
function sampleSuiteScript() {
message.create({
title: "Message Module",
message: "Successfully loaded the message module",
type: message.Type.CONFIRMATION
}).show();
}
return {
pageInit: sampleSuiteScript
};
});