ANS-1537 · SUITESCRIPT DEVELOPMENT

How to Control User Event Script Execution During Record Submission in NetSuite

Understand how to manage user event triggers when submitting records programmatically in NetSuite, considering differences between SuiteScript versions.

Short answer

While SuiteScript 1.0 allowed disabling user event triggers during record submission using nlapiSubmitRecord with a disabletriggers option, SuiteScript 2.x's record.save() method does not officially support this specific option. Developers should be aware of this distinction when migrating or developing new scripts.

Scenario

A NetSuite scheduled script needs to submit a record programmatically. The requirement is to prevent associated user event scripts from executing during this submission process to avoid unintended side effects or infinite loops.

Solution

In SuiteScript 1.0, a scheduled script could prevent user event scripts from triggering during a record submission. This was achieved by passing specific options to the nlapiSubmitRecord function. The syntax used was:

nlapiSubmitRecord(record, { disabletriggers : true, enablesourcing : true })

For SuiteScript 2.x, which is the current recommended version for NetSuite development, the equivalent method for submitting a record is record.save(). However, the disabletriggers option, which was available in SuiteScript 1.0, is not officially documented or supported for the record.save() method in SuiteScript 2.x. While enablesourcing: true remains a valid option for controlling field sourcing, the direct functionality to disable user event triggers via an option on record.save() is not present in the same manner. Therefore, when using record.save() in SuiteScript 2.x, the call would typically look like this, without the disabletriggers option:

record.save({ enablesourcing : true })

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant