How To Overcome Script Execution Time Exceeded Error in Schedule script 2.0?

As a NetSuite Solution Provider we consistently gives focus on optimizad netsuite customization and netsuite Support.
The disadvantage of schedule script in suitescript 2.0 is that yield script functionality which is there in 1.0 has been taken away. Yield script had a great advantage of being able to resume the script from the point it stopped when time or usage limit exceeded.Workaround in schedule suitescript 2.0 to overcome time exceeded error is to monitor the time taken to process the script. If it reaches near the time limit of 3600s after which script errors out, schedule script can be called again by passing the point at which it needs to resume. For eg: if you are processing 100k records and script is able to process only 50k after 55 mins, then script can be rescheduled by passing the internalid of record from which script needs to process. This internalid is passed in the script parameter.

Example code:

var startTime = new Date().getTime();

for(var i=0;i<search.length;i++)


var endTime = new Date().getTime();
var timeElapsed = (endTime*0.001) – (startTime*0.001);
if (timeElapsed > 3300)// more than 55 mins
var scheduledScriptTask = task.create({
taskType: task.TaskType.SCHEDULED_SCRIPT,                                                                                  scriptId: runtime.getCurrentScript().id,
params: {custscript_resume_point: internalid}

//logic to process records

Feel free to reach out TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customization, netsuite Support,netsuite Trainingcontact us at:

Email :

Facebook :

Linkedin :

Leave a Reply