What is Define() function in Netsuite SuiteScript 2.0
In SuiteScript 2.0 , script uses define() function to load the modules before execution
Use the
When you use the
In SuiteScript 2.0, the
Developer must use the
Use the
define()
function to load SuiteScript 2.0 modules and create custom modules.When you use the
define()
function, it loads all dependencies before it executes any logic.In SuiteScript 2.0, the
define()
function returns an object that encapsulates the module you are defining.Developer must use the
define()
function in his/her entry point
script. The return statement must include at least one entry point and
entry point function. All entry points must belong to the same script
type. /**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record'],
function (record)
{
function method1(context)
{
//add your logic here
}
function method2(context)
{
// add your logic here
}
function method3(context)
{
// add your logic here
}
return {
beforeLoad: method1,
beforeSubmit: method2,
afterSubmit: method3
};
});
Can I use define and require function both in same script?
ReplyDeleteHi , No we cant use both at same time.
ReplyDeleteAlso Define return value but Require don't.
also When you use the define() function, it loads all dependencies before it executes any logic
where as When you use the require() function, dependencies are not loaded until they are needed.
can i run the script with out both functions.
ReplyDeleteOne at a time.
ReplyDeletenot both together. I explained answer above.