首页 文章

如何获取脚本上下文参数

提问于
浏览
2

我是这个netsuite的新手 . 我需要从用户事件脚本调用调度脚本,然后在调度脚本中检索传递的param值 . 我正在尝试这段代码:

// 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);
 }
}

在预定的脚本上:

function scheduled(type) {

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

但是我无法检索预定脚本的值 . 在日志中它显示为空白 . 任何人都可以帮我解决一下,上面的代码出了什么问题?

先感谢您 .

3 回答

  • 0

    在预定脚本中注册此参数 . 跟着这些步骤

    • 导航到此计划脚本的“编辑”页面 .

    • 单击参数选项卡

    • 单击“新建参数”

    • 添加具有相同ID的参数

  • 0

    您的脚本看起来正确 .
    检查预定脚本中的以下两项内容:

    1. 'custscript_recordid'这必须是预定脚本中的脚本参数
      2.检查该字段的首选项 . 它应该是'user'或'company' .
  • 1

    请尝试以下代码 .

    var params = 
    {
        custscript1:Customer_ID,custscript2:BGS,custscript3:AcCoordinator,custscript4:District
    };
    nlapiScheduleScript('customscript156','customdeploy1',params);
    

相关问题