Submitting an On-Demand Scheduled Script Instance from Another Script

Important:

Before you submit a scheduled script, be sure you know how SuiteCloud Processors works.

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

You can submit an on-demand script only if there isn’t another unfinished instance of it running.

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

  1. First, create your scheduled script entry point, which includes your JavaScript file and script record. Need an example? Check out the SuiteScript 2.x Scheduled Script Type Code Sample. New to scripts? 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’s not already checked. You can’t submit the script 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, call task.create(options) This 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