SuiteScript 2.x Standard and Dynamic Modes

When you create, copy, load, or transform records in SuiteScript, you can work with records in standard or dynamic mode.

Standard mode:

When a SuiteScript 2.x script creates, copies, loads, or transforms a record in standard mode, the record’s body fields and sublist line items are not sourced, calculated, and validated until the record is saved with Record.save(options). You might also see this referred to as "deferred dynamic mode" in the SuiteScript help.

When you work with a record in standard mode, in most cases, you don't need to set values in any particular order. When you submit the record, NetSuite will process the fields and sublist items in the right order, no matter how your script is organized. See Getting Text in SuiteScript 2.x Record Modes.

Dynamic mode:

When a SuiteScript 2.x script creates, copies, loads, or transforms a record in dynamic mode, the record’s body fields and sublist line items are sourced, calculated, and validated in real time. Dynamic mode makes the record behave like it would in the NetSuite UI.

Note:

In dynamic mode, the Legacy Tax field Tax Code isn't automatically transferred when a requisition becomes a purchase order. For more information, see Tax Code Limitations When Using SuiteScript 2.x.

In dynamic mode, the order of setting field values is important. This might feel limiting to some developers. You'll probably need to check the UI often when scripting in dynamic mode. For instance, when creating an invoice in the UI, you wouldn't set the Terms field before the Customer field. That's because setting the Customer field will override the Terms field value. On an invoice, the value of Terms is sourced from the terms specified on the Customer record. This behavior also applies to dynamic scripting. If you don't set field values in the right order in your script, some values might get overridden.

How you can tell if a record is in dynamic mode:

You can determine if a record is in dynamic mode using these two SuiteScript 2.x properties:

Record Modes and User Event Scripts

User event scripts that use newRecord or oldRecord objects always run in standard mode. FThis is why you might see the SSS_INVALID_API_USAGE error in these situations:

Getting Text in SuiteScript 2.x Record Modes

In dynamic mode, you can use Record.getText(options) without limitation, but in standard mode, there are some limits. In standard mode, you can use this method only in these situations:

Record Module Method Considerations

Be aware that the record.create(options), record.copy(options), record.load(options), and record.transform(options) methods work in standard mode by default. To use these methods in dynamic mode, set the .isDynamic property for each one.

Related Topics

General Notices