Question

I'm new to this netsuite. I have a requirement to call a scheduled script from an user event script and there by to retrieve the passed param values in the scheduled script. I'm trying this code :

// before submit 

function userEventBeforeSubmit(type) {

if (type == 'edit') {
    var recId = nlapiGetRecordId();
    var params = new Array();
    params['custscript_recordid'] = recId;

    var status = nlapiScheduleScript('customscript_req_schedule','customdeploy1', params);
    nlapiLogExecution('DEBUG', 'Status', status);
 }
}

on the scheduled script:

function scheduled(type) {

if (type == 'userinterface' || type == 'scheduled' || type == 'ondemand') {
    nlapiLogExecution('DEBUG', 'Scheduled Script', type);
    var parentId = nlapiGetContext().getSetting('SCRIPT','custscript_recordid');
....
...
}

But I'm unable to retrieve the value on the scheduled script. On the log it is displaying blank. Can any one help me to figure it out, what went wrong in the above code??

Thank you in advance.

Was it helpful?

Solution

Register this parameter in your scheduled script. Follow these steps

  1. Navigate to Edit page of this schedule script.
  2. Click on parameters tab
  3. Click New parameter
  4. Add the parameter with same id

OTHER TIPS

Your scripts looks correct.
Check the following 2 things in the scheduled script :
1. 'custscript_recordid' this must be a script parameter in the scheduled script
2. check the preference of that field. It should be either 'user' or 'company'.

Try the below code.

var params = 
{
    custscript1:Customer_ID,custscript2:BGS,custscript3:AcCoordinator,custscript4:District
};
nlapiScheduleScript('customscript156','customdeploy1',params);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top