How to prevent a UE script from running when an it...
# suitescript
j
How to prevent a UE script from running when an item is updated by a Mass Update? I disabled the "Custom Mass Update" context, but I am pretty sure that only covers scripted Mass Updates. I do not see an option for standard Mass Updates.
d
you could log the
runtime.executionContext
in the UI script while running generic Mass Update and see what it comes back with, then exclude executing the UE script logic against that value although I agree, I am not seeing a standard Mass Update option under https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4296646855.html
j
Turns out Mass Update is a USEREVENT
I really wish that was not the case, my script only throws errors when a Mass Update takes place for some reason
d
idk what errors you're getting, but maybe can try/catch for that specifically to handle also note at bottom of https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N666653.html "in the case of the mass update, the full record is not passed to the user event script; instead, only the field(s) actually changed by the mass update are passed" - so maybe you can look at the UE context Record instance to determine if is under Mass Update scenario, if they look different than normally expected
j
Hope there is a better solution, but, one way to work around this is to flag items during the mass update (i.e. a checkbox to "prevent ue script" being checked) to identify not to run the core of the ue script, except probably to uncheck the box.
j
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "UNEXPECTED_ERROR",
  "message": null,
  "stack": [
    "anonymous(N/serverRecordService)",
    "beforeSubmit(/SuiteScripts/setEqualPrice_V2.js:24)"
  ],
  "cause": {
    "type": "internal error",
    "code": "UNEXPECTED_ERROR",
    "details": null,
    "userEvent": "beforesubmit",
    "stackTrace": [
      "anonymous(N/serverRecordService)",
      "beforeSubmit(/SuiteScripts/setEqualPrice_V2.js:24)"
    ],
    "notifyOff": false
  },
  "id": "23279591-2319-4451-a96c-c3f1a61fe1bb-2d323032322e30392e3038",
  "notifyOff": false,
  "userFacing": false
}
Ahhh, the script is trying to get a matrix sublist value, if that value is not in the mass update, it is trying to get something that's not there.
Well hold on, when a user manually changes a value, it's USERINTERFACE, what else uses USEREVENT?
I can probably get away with excluding USEREVENT
👍 1
Disabling User Event Script context from the deployment worked
b
Execution Context Types describes when the user event type is used
in general its for bulk actions
z
You can check to see if the full context is there and then if it's not, you can load the full record in these situations. Kinda dumb, but it works.