Friday, September 21, 2018

Pass a Value from the Before Submit to the After Submit Script

This might come in handy for scenarios where users need to use a transient variable across Before Submit to an After Submit.

One of the ways to have this done is to define a session object on the Before Submit script using the setSetting method of nlobjContext. The After Submit script will get the value of this session object using the getSettingMethod.


Sample Code snippets:

 

Before Submit

function beforesubmit(type)
{
 nlapiGetContext().setSetting('SESSION','testsessionobject','test value');
}

 


 

After Submit

function aftersubmit(type)
{
 var testparam = nlapiGetContext().getSetting('SESSION', 'testsessionobject');
 nlapiLogExecution('debug','test param',testparam);
}

 

 

Please refer to the Help Guide for the complete information on how to use nlobjContext as well as its methods such as getSetting and setSetting. From the Help Guide sidebar, just navigate to SuiteCloud (Customization, Scripting, and WebServices) > SuiteScript > SuiteScript API > SuiteScript Objects > Standard Objects.

 

No comments:

Post a Comment