When creating, copying, loading, or transforming records in SuiteScript, developers can choose between standard and dynamic modes. Each mode has unique behaviors regarding how record fields and sublist items are handled.
Standard Mode
In SuiteScript 2.x, if a script operates in standard mode, the record’s body fields and sublist items are only sourced, calculated, and validated upon saving the record using Record.save(options). Standard mode, also known as “deferred dynamic mode,” allows fields to be set in any order without affecting the final data. Once the record is saved, NetSuite processes the fields and sublist items in the required order, regardless of the organization within the script. The SuiteScript help documentation may refer to both “standard mode” and “deferred dynamic mode.”
When working in standard mode, developers can generally set values in any sequence. After submission, NetSuite processes body fields and sublists in the correct order. For more details, refer to SuiteScript 2.x documentation on Getting Text in Record Modes.
Dynamic Mode
In dynamic mode, SuiteScript 2.x processes a record’s body fields and sublist items in real time, replicating the record behavior in the NetSuite UI. Here, the order in which fields are set is critical, as some fields may override the values of others. For instance, when scripting an invoice, setting the Terms field before the Customer field may result in Terms being reset based on the customer’s default settings. This sequence constraint requires close alignment with the UI’s behavior to ensure accurate results.
To determine if a record operates in dynamic mode, SuiteScript 2.x offers two properties:
Record.isDynamic (for server-side scripts)
CurrentRecord.isDynamic (for client-side scripts)
Record Modes in User Event Scripts
User event scripts use standard mode exclusively when working with newRecord or oldRecord objects provided by the script context. Attempting to apply dynamic-specific methods, like using Record.getText(options) before Record.setText(options) on a newly created or copied record, will trigger the SSS_INVALID_API_USAGE error.
In standard mode, Record.getText(options) is available only in the following cases:
When the field has already been set using Record.setText(options)
When loading or copying a record, Record.getText(options) can be used on fields unless they’ve been modified by Record.setValue(options)
Using Record Module Methods
Methods such as record.create(options), record.copy(options), record.load(options), and record.transform(options) default to standard mode. To enable dynamic mode for these methods, set the .isDynamic property on each method.
By understanding and applying these nuances, SuiteScript developers can better control record processing and streamline their scripts for optimal integration with the NetSuite platform.