小编Ale*_*ndr的帖子

如何使用按钮启动预定脚本?

我想以执行计划脚本的形式创建一个按钮,但我尝试的任何方法都不起作用

我尝试过 addButton 方法来调用一个为预定脚本创建任务的函数,但它仅在表单加载时执行

/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define(["N/task", "N/ui/serverWidget"], function(task, serverWidget) {
  function beforeLoad(context) {

    context.form.addButton({
      id: "custpage_setTask",
      label: "Execute scheduled",
      functionName: executeScheduled()
    });
  }

  return {
    beforeLoad: beforeLoad
  };

  function executeScheduled() {
    var scriptTask = task.create({ 
      taskType: task.TaskType.SCHEDULED_SCRIPT,
      scriptId: 'customscript_sdr_ss_product_shortage',
      deploymentId: 'customdeployprodshortsearch'
     });

    var scriptTaskId = scriptTask.submit();

    log.debug('scriptTaskId', scriptTaskId);
  }
});
Run Code Online (Sandbox Code Playgroud)

执行计划的脚本,但仅在表单加载中,然后按钮不执行任何操作,请帮助并感谢您的阅读

button netsuite suitescript

0
推荐指数
1
解决办法
4159
查看次数

标签 统计

button ×1

netsuite ×1

suitescript ×1