Submitting an On Demand Scheduled Script Instance from Another Script

Important:

Before you submit a scheduled script instance for processing, you must understand how SuiteCloud Processors works.

You can programmatically submit a scheduled script instance to SuiteCloud Processors using the task.ScheduledScriptTask API.

You can submit an on demand instance of the script only if there is no other unfinished instance of the same script.

To submit an on demand scheduled script instance from another script:

  1. First, create your scheduled script entry point script. This includes your JavaScript file and its associated script record. To review a scheduled script example, see Scheduled Script Sample. If this is your first script, see SuiteScript 2.x Hello World and SuiteScript 2.x Entry Point Script Creation and Deployment.

  2. On the associated script record, select the Deploy Script button.

  3. When the script deployment record loads, click the Deployed box if it is not already checked. A scheduled script cannot be submitted for processing unless this box is checked.

  4. Review the scheduled script deployment field descriptions at Scheduled Script Deployment Record.

  5. Set the Status field to Not Scheduled.

  6. Set the remaining body fields.

  7. Click Save.

  8. In the server script where you want to submit the scheduled script instance, call task.create(options) which returns a task.ScheduledScriptTask object:

                    var scriptTask = task.create({
        taskType: task.TaskType.SCHEDULED_SCRIPT
    }); 
    
                  
  9. Set the ScheduledScriptTask.scriptId and ScheduledScriptTask.deploymentId properties:

                    scriptTask.scriptId = 1234;
    scriptTask.deploymentId = 'customdeploy1'; 
    
                  
  10. Call ScheduledScriptTask.submit() to submit the scheduled script instance to SuiteCloud Processors.

                    var scheduledScriptTaskId = scriptTask.submit(); 
    
                  

Related Topics

General Notices