A customer has many user event scripts that run be...
# suitescript
s
A customer has many user event scripts that run before/after submitting a transaction in the UI, like Sales Orders. When I create a sales order programmatically through a scheduled suitescript (NOT another user event script), however, none of those user events run on the new sales order. How would I go about triggering their event scripts in a generic/reusable way, assuming I don't know what all their script names are? (Because I genuinely don't)
b
general answer is to change the code / script deployment of each script
s
what?
b
find every user event script that is supposed to run and change them so that they do run
they aren't running either through a script audience that excludes your script
s
and how would i do that
b
or code that excludes your script
s
I so far know of one user event script thats supposed to run, and I see that it runs before submit function and after submit function
I assume that means when you click the submit button in the UI
But I'm kind of "submitting" the sales orders through suitescript, there doesn't seem to be any distinction on the script in netsuite for that
b
find the script deployment of the user event script that should run
s
I see the audience is set to All Roles, with some subsidiaries listed
b
is your user role in one of those subsidiaries
s
my user role being administrator?
No administrator is not explicitly listed. I dont actually understand what the subsidiaries mean
b
subsidiaries limits the user event to only run on users from the listed subsidiaries
s
alright that is the script deployment, idk why it posted in the main thread instead of this one
b
if your employee record does not have those subsidiaries set, the user event script wont run for your user
s
What about this would say "don't execute if the sales order is submitted via scheduled suitescript"?
okay i can try that
but i dont understand why a scheduled suite script is relying on my user role
b
it generally doesn't. But it does if you manually run it
s
hmm yea i am manually triggering it to test so hopefully this will solve the issue, thanks
b
its more common for the code of the script to limit when its run
s
the list of subsidiaries under employee dropdown doesnt actually match up with what was on the script deployment somehow
you mean the code of the user event script?
b
yes
s
The subsidiaries in the deployment record are listed "XYZ Companies: XYZ Inc" but under the employee records, the options dont have colons like that. I'm already subsidiary "XYZ Inc"
b
if its ss2, it might use the N/runtime module to limit which executionContext are allowed to run the script
XYZ Companies is the parent subsidiary of XYZ Inc
that means your role should have access to all the children of XYZ Companies
s
oh i think that might be the case, I do see that it might only execute under "WEBSTORE" context
this might be a change the customer needs to make then
hm only the beforeSubmit has the WEBSTORE qualifier, so one would think the afterSubmit would still be working through my scheduled suitescript. so idk
b
how do you tell if the script has run or not
s
Because fields are not populating on the SO (that get populated via the user event script) until they edit/submit the record apparently
b
in general, it sounds like whoever wrote the user event script knows what they are doing
best practice is to not modify the current record in an after submit script
so the after submit might not change the record
s
I mean it sounds like it is supposed to change the record -> it populates fields that don't get populated via my script, only when the record is submitted in the UI
Its also just got nothing in the execution logs under the deployment
b
the execution logs are set to error. i wouldn't expect any logs unless there are errors
s
I mean doesn't it show when the script runs, regardless of if any actual log statements appear
Under Scheduled script status it isn't there but idk if that only shows... scheduled scripts, tbh i have no idea where to see the run logs of a user event script, I only know that theyre saying fields are not being populated unless they click submit through the ui, implying it isnt running when my script runs
b
there is nothing that shows if the user event script runs or not
at best there are logs, which must be coded
s
oof ok