如何使用SuiteScript 2.0版本在Netsuite中重新计划计划脚本 [英] How to Reschedule the Schedule Script in Netsuite using SuiteScript 2.0 version

查看:100
本文介绍了如何使用SuiteScript 2.0版本在Netsuite中重新计划计划脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重新安排计划脚本,这是在达到州长限制之前使用计划脚本的时间. Netsuite中的日程表脚本有10,000个单位. 在SuiteScript 1.0版本中,可以通过"nlapiScheduleScript()api"实现重新计划,而在SuiteScript 2.0版本中,如何重新计划脚本.

I want to reschedule the schedule script , when the schedule script usage before hitting the governor limits. schedule script in Netsuite has 10,000 units. In SuiteScript 1.0 version, rescheduling is acheived by "nlapiScheduleScript() api " but in SuiteScript 2.0 version how to reschedule the script.

提前感谢我.

推荐答案

N/taskN/runtime模块具有所需的内容.您将使用N/task进行重新计划,并使用N/runtime来获取当前脚本信息.

The N/task and N/runtime modules have what you're looking for. You'll use N/task to do the rescheduling, and N/runtime to get the current script info.

没有确切的代码,我无法给出一个非常具体的示例,但是您安排好的脚本最终看起来像这样:

Without your exact code I can't give a very specific example, but your scheduled script will end up looking generally something like:

/**
 * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 */
define(['N/task', 'N/runtime'], function(task, runtime) {

    /**
     * Reschedules the current script and returns the ID of the reschedule task
     */
    function rescheduleCurrentScript() {
        var scheduledScriptTask = task.create({
            taskType: task.TaskType.SCHEDULED_SCRIPT
        });
        scheduledScriptTask.scriptId = runtime.getCurrentScript().id;
        scheduledScriptTask.deploymentId = runtime.getCurrentScript().deploymentId;
        return scheduledScriptTask.submit();
    }

    function execute(context) {

        // Do stuff...

        while(...) {
            // Do processing in loop

            // Check remaining usage and reschedule if necessary
            if (runtime.getCurrentScript().getRemainingUsage() < 100) {
                var taskId = rescheduleCurrentScript();
                log.audit("Rescheduling status: " + task.checkStatus(taskId));
                return;
            }
        }
    }

    return {
        execute: execute
    };
});

这篇关于如何使用SuiteScript 2.0版本在Netsuite中重新计划计划脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆