Create Multiple Sales Records Using a Scheduled Script

The following sample shows how to use a scheduled script to create multiple sales records and log the record creation progress.

Note:

This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.

          /**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/

// This script creates multiple sales records and logs the record creation progress.
define(['N/runtime', 'N/record'], function(runtime, record) {
    return {
        execute: function(context) {
            var script = runtime.getCurrentScript();
            for (x = 0; x < 500; x++) {
                var rec = record.create({
                    type: record.Type.SALES_ORDER
                });
                script.percentComplete = (x * 100)/500;
                log.debug({
                    title: 'New Sales Orders', 
                    details: 'Record creation progress: ' + script.percentComplete + '%'
                });
            }
         }
    };
}); 

        

General Notices