Prevent User Event Scripts Running On CSV Imports
Published on
February 29, 2024 at 7:27:56 AM PST February 29, 2024 at 7:27:56 AM PSTth, February 29, 2024 at 7:27:56 AM PST
Scenario
With the "Run Server SuiteScript and Trigger Workflows" option enabled (inSetup > Import/Export > CSV Import Preferences) User Event scripts deployed on a record will also run for CSV Imports for the very same record.
However, one may wish to prevent such behavior.
Solution
To prevent a script or a part of a script from running on CSV Import, one needs to enclose one's code by the following if statement.
SS 1.0
var currentContext = nlapiGetContext(); if(currentContext.getExecutionContext() !='csvimport') { // Do not forget to close the if statement at the end of the code }
SS 2.0
if(runtime.executionContext != runtime.ContextType.CSV_IMPORT) { // Do not forget to close the if statement at the end of the code }
In case you need to prevent all of the code from running do as follows.
SS 1.0
SS 2.0
If you would like to prevent only part of your script from running for a CSV Import, please do the following.
SS 1.0
SS 2.0