簡體   English   中英

NetSuite - suitescript:重新安排 Map/Reduce 腳本以在特定時間失敗后運行

[英]NetSuite - suitescript : Rescheduling a Map/Reduce script to Run after a specific time on failure

我正在使用 Suitescript 2.0。 在那里,我試圖為特定類型的錯誤重新安排腳本。

我得到了以下代碼,可用於立即重新安排腳本。

var scriptTask = task.create({
     taskType: task.TaskType.MAP_REDUCE
});
scriptTask.scriptId = 'customscript_id';
scriptTask.deploymentId = 'customdeploy_id';
var scriptTaskId = scriptTask.submit();

但我主要是在尋找一些選項來在某個時間后運行它,比如一個小時后。

是否可以通過將任何類型的參數傳遞給上述任務來實現?

任何其他替代方法也會有所幫助。

我遇到了類似的問題,在您的情況下,我需要將我的日程安排延遲一段時間,這應該是相同的 map/reduce 腳本。

我用這種方法修復了它。

這是該方法的示例代碼。

/**
  • @NApiVersion 2.x
  • @NScriptType ScheduledScript
  • @NModuleScope SameAccount */define(['N/file', 'N/record', 'N/render', 'N/runtime', 'N/search', 'N/ui/serverWidget', 'N/format ', 'N/任務', 'N/log'],

功能(文件、記錄、渲染、運行時、搜索、serverWidget、格式、任務、日志){

/**
 * Definition of the Scheduled script trigger point.
 *
 * @param {Object} scriptContext
 * @param {string} scriptContext.type - The context in which the script is executed. It is one of the values from the scriptContext.InvocationType enum.
 * @Since 2015.2
 */
function execute(scriptContext) {
     wait(20000); // it waits 20 sec       
   //whatever you want to do
}
function wait(ms){
   var start = new Date().getTime();
   var end = start;
   while(end < start + ms) {
     end = new Date().getTime();
  }
}



return {
    execute: execute
};

});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM