Hi guys, I'm trying to offload a user event (sendi...
# suitescript
k
Hi guys, I'm trying to offload a user event (sending an email) to a scheduled script using
N/task
, but am running into the
FAILED_TO_SUBMIT_JOB_REQUEST_1
error. I was advised last time to remove the
scriptDeployment
id from my
task.create
option object, so what I have looks a little like:
Copy code
const scriptTask = task.create({taskType: task.TaskType.SCHEDULED_SCRIPT});
scriptTask.scriptId = SCHEDULED_SCRIPT_HELPER_SCRIPT_ID;
scriptTask.params = {};  
scriptTask.params[SCHEDULED_SCRIPT_HELPER_PARAM_ID] = JSON.stringify(context);
scriptTask.submit();
with the understanding that NS would identify the script, select an unused deployment id, and use any unused deployment to run the script. That way, I could create ~10 deployments for a script for example, and NS would choose one that's not being used. I've looked through these script deployments and the majority of executions are on the first deployment, some on the 2nd deployment, etc. etc. The highest number of deployment that's ever been used is the 6th deployment. However... I'm still getting
FAILED_TO_SUBMIT_JOB_REQUEST_1
, even though there are unused deployments available. Is there some other part of the equation I'm not considering that would cause a job to fail to be submitted? Also, is there a better way to handle checking if a job is able to be submitting it without actually submitting it (e.g.,
try/catch
?). Thanks for any help šŸ™‚
b
the only thing that looks abnormal to me is the params
try removing it and see if it works
k
I mean, it works fine several hundred times a day, it's just when there are multiple job submits is when it becomes a problem
b
is there a nice reason message?
k
not really, just
":"Failed to submit job request: INQUEUE."
b
that would suggest that the chosen deployment is already in queue
you could try submitting a netsuite support case to see what they say
if i just wanted this to work, you could try a try catch
k
I think I'll give the try catch a shot yeah for the time being, at least it'd prevent the error showing to my users
e
are these scheduled script deployments scheduled? They should be not scheduled.
k
they are not scheduled
m
I've done something like this with a workflow that just runs a workflow action script and trigger the workflow asynchronously. The advantage is that you don't have to worry about having deployments available, but on the other hand you won't get any concurrency. I've also heard of people ad hoc creating new deployments if there aren't any available. @alien4u
k
that's the thing though, there definitely are deployments available
if I look at the instances of the deployments attached to the scheduled script, some of them have never been run (specifically the 7th, 8th, 9th, and 10th deployment created for that script)
e
I wonder if it is because you have no processors available… INQUEUE tells me that even the previously triggered deployment hasn’t begun processing yet. Otherwise, it would read ā€œINPROGRESSā€ - so perhaps you are all out of processors/queues
b
the guess is that netsuite chose an already queued deployment to run, potentially because it doesn't handle concurrency gracefully
k
it's a bit strange... I received a failed to submit error @11:53... if I go and look at the list of instances of my scheduled script for that time period, it's only ever using the very first deployment around that time, it's not like a bunch of deployments were being used up
b
you would want to look at the records created/edited, if multiple are being created at the time, concurrency issue
k
A scheduled script can be submitted for processing only if there is no unfinished scheduled script task for the same script ID and script deployment ID.
From the SS docs, perhaps it's just not a good idea to leave the
scriptDeployment
parameter blank and assume NS will figure it out? I wonder if creating a new deployment for each task fire then deleting the deployment at the end of the fired scheduled script would run without this issue
m
Another option if you can live with up to 15 min delay is to create a custom field as flag and use a M/R script to check and handle the logic instead of SS
k
hmm yes, that may be the more logical way to do things - it's not like the email has to go out the second the items are shipped
e
you don’t necessarily need to wait the 15 minutes, then. you can trigger the M/R immediately… again, assuming it is Not Scheduled (just like Scheduled scripts)
k
i don't see how that would help with the error I'm getting šŸ˜›
i imagine i'd get something similar with `N/task`ing a MR script
133 Views