2

Refer to the SuiteScript 2.0 API doc for NetSuite. To set a value of a sublist field, use the "Record.setSublistValue(options)" while in STANDARD mode.

When working in DYNAMIC mode, set a sublist field value using the following methods one by one:

  1. Record.selectLine(options)

  2. Record.setCurrentSublistValue(options)

  3. Record.commitLine(options)

But what are the STANDARD and DYNAMIC modes? What's their difference?

skyline
  • 443
  • 9
  • 31

2 Answers2

5

In short, DYNAMIC mode runs field sourcing and validation as you set each field, whereas STANDARD mode (or Deferred Dynamic Mode, as it's also called in NetSuite documentation) does not run field sourcing and validation until you call record.save().

This means that DYNAMIC mode acts more like the UI, where the order in which you set fields matters. If you manually set a sourced field, the value you end up with could depend on whether you set it before or after the field that triggers the sourcing. In STANDARD mode this is not an issue - you will always end up with the same values.

More information can be found here (NetSuite login required).

Krypton
  • 4,394
  • 2
  • 9
  • 13
1

Dynamic means it reacts immediately as it is manipulated. For example, when you add item into an order loaded dynamically, fields like total price will be recalculated immediately and you get them from the record without saving the order.

If the record is loaded non-dynamically, the total price field will have value from time when the record was loaded and will not be updated until you save the record.

The record is loaded in dynamic mode when you use isDynamic: true in record.load call:

var r = record.load({
    type: record.Type.SALES_ORDER,
    id: 123,
    isDynamic: true,
});

Working with non-dynamic records is faster - don't use dynamic if you are not going to use it. (For example, for obtaining the total price before saving the record.)

Honza
  • 974
  • 10
  • 18