is it possible to combine a validation error/warni...
# suitescript
p
is it possible to combine a validation error/warning in the same script for when the event is done in the UI versus a CSV Import or would the recommendation be to split these 2 events into different script?
s
They are different contexts, so yes you could (and probably want to) handle them differently. CSV is XEDIT and regular ui is EDIT, so check check the context and follow your different paths
p
thanks. can you do this in a beforesubmit script and throw an alert versus an error?
s
You certainly cant alert on the CSV path
p
ok
s
if you want to stop a record from being saved in the UI, client script is the more appropriate path
beforeSubmit does not have a return type, so whatever you do does not stop the save, unless you throw something. An alert would be a better user experience and give them the chance to fix whatever is wrong
p
thanks
so best practice is to create a version of the script for csv imports versus the ui?
s
No, if you want user interaction with the save, use a client script. CSV/Edit mode can both live in the user event, just check
scriptContext.type
, these relate to the
scriptContext.UserEventType
enumeration (EDIT, XEDIT, CREATE, etc) and check
runtime.executionContext
and handle your desired behavior accordingly