hi guys, Im trying to do rescheduling in 2.0 for s...
# suitescript
s
hi guys, Im trying to do rescheduling in 2.0 for schedule script. and using N/Task module im calling this function function rescheduleCurrentScript() { var scheduledScriptTask = task.create({taskType: task.TaskType.SCHEDULED_SCRIPT}); scheduledScriptTask.scriptId = runtime.getCurrentScript().id; scheduledScriptTask.deploymentId = runtime.getCurrentScript().deploymentId var schedule_script_task = scheduledScriptTask.submit(); return schedule_script_task; } whenever this function is called my script is executing for repeatedly for the first 500 search results out of 3000 results how do i need to do the changes so that this rescheduling works for all the 3000 results.
s
You are running out of governance. A scheduled script has 10,000 governance units available. Each call to scheduledScriptTask.submit() will use 20 governance units, meaning you can call that at most 500 times in a scheduled script before the script halts, so what you are saying makes perfect sense. You should be seeing a limit exceeded error getting logged for your script. There’s only two ways to handle this: check your remaining usage and re-schedule the script you are in to handle the remaining results when you get close to 0. You’ll need to have a way to pick up where you left off so you don’t keep repeating the same 500. Probably the more preferred way would be to convert this to a Map/Reduce script as it can handle large batches of results without concern for running out of governance.
I’m a little confused by what you are doing though. Is the script that is running and gets the 3000 results re-scheduling itself (the same script and deployment)? I can see a script re-scheduling itself at most once, to run again after running out of usage, but not sure what the purpose of re-scheduling itself 3,000 times would be.
🤷‍♂️ 1
t
Just make it a map reduce. Thats what they are built for. THis is an SS 1.0 design pattern
✔️ 1