Hi everyone, I call Schedule Script inside UE scri...
# suitescript
n
Hi everyone, I call Schedule Script inside UE script (aftersubmit) by using N/task.
Copy code
var scriptTask = task.create({
        taskType: task.TaskType.SCHEDULED_SCRIPT,
        scriptId: ...,
        deploymentId: ...,
        params: {...}
      });
      var scriptTaskId = scriptTask.submit();
It repeats creating the following errors, because the UE script is called on CSV import which has hundreds of records.
Copy code
{"type":"error.SuiteScriptError","name":"FAILED_TO_SUBMIT_JOB_REQUEST_1","message":"Failed to submit job request: INPROGRESS.","stack":...}
Are there any efficient ways to avoid this error? Though I use 7 deployments, it still keeps the error.
b
multiple approaches to the problem, depending on how serious the solution
most basic is to create more deployments and not specify the deployment id so that netsuite chooses an unused deployment
the weakness here is that netsuite's logic isnt actually thread safe, you can still get the in progress error even if there are unused deployments
you can create tasks in a try-catch loop if you want to have a lazy solution since the problem is fairly uncommon
👍 1
a variation of the technique is to create your own deployment programmatically and use that instead
the more advanced approach is to essentially make a queue and have your script process multiple records at a time instead of one record per task
its what you usually end up implementing if you have an error handling mechanism to retry failed records
you can get by with fewer deployments if they process multiple records at a time
it tends to be easier if you can get away with a scheduled deployment since you wouldnt need to use the user event to task the scheduled script