NetSuite Record Syntax for SuiteScript 2.x Operations

Learn the syntax for managing NetSuite records in SuiteScript 2.x, focusing on standard and dynamic modes for efficient scripting.

·2 min read·View Oracle Docs

The following section explains the syntax for managing records within NetSuite using SuiteScript 2.x, emphasizing how to handle records effectively for various operations.

What is Record Syntax?

Record syntax in SuiteScript 2.x refers to the structured way of interacting with NetSuite records. This includes creating, copying, loading, and transforming records using object-oriented principles.

How Do Standard and Dynamic Modes Differ?

When working with records, SuiteScript 2.x offers two modes: standard mode and dynamic mode.

Standard Mode

  • Description: In standard mode, a record's body fields and sublist line items are not sourced or validated until the record is saved using the Record.save(options) method. This means developers can set field values without concern for the order during script execution.
  • Best Practice: Take advantage of the flexibility this mode provides, especially in scenarios where field ordering is complex or non-linear.

Dynamic Mode

  • Description: In dynamic mode, field values are sourced and validated in real-time, mimicking the behavior of the record in the NetSuite user interface. Values must be set in a specific order to ensure the expected results.
  • Best Practice: Always set field values in the same sequence as they appear in the UI to avoid inconsistencies.

Methods for Working with Records

The following methods can be utilized for record operations:

  • Creating: Use record.create(options) to instantiate a new record.
  • Copying: Use record.copy(options) to duplicate an existing record.
  • Loading: Use record.load(options) to access a specific record by ID.
  • Transforming: Use record.transform(options) to convert one record type into another.

Important Method Details

To activate dynamic mode for any of these methods, pass the argument isDynamic: true:

suitescript
var objRecord = record.load({
type: record.Type.SALES_ORDER,
id: '6',
isDynamic: true
});

Related Resources

For further reference, visit:

Who This Affects

This information is particularly relevant for:

  • Developers: Scripting record interactions effectively.
  • Administrators: Understanding record management practices.

Key Takeaways

  • Record syntax follows object-oriented principles in SuiteScript 2.x.
  • Use standard mode for flexibility, dynamic mode for UI-like behavior.
  • Always follow the correct order of setting values in dynamic mode.
  • Familiarity with N/record module is essential for effective scripting.

Frequently Asked Questions (4)

How can I enable dynamic mode when loading a record in SuiteScript 2.x?
To enable dynamic mode when loading a record, include the argument `isDynamic: true` in the options object passed to `record.load(options)`. This will allow the record to behave similarly to the NetSuite UI where fields are sourced and validated in real-time.
What is the key advantage of using standard mode for record operations in SuiteScript 2.x?
The key advantage of using standard mode is its flexibility in terms of field value setting. Fields do not need to be set in a particular order and changes are not validated until the record is saved, making it ideal for scripts where field ordering is non-linear or complex.
What should developers keep in mind when setting field values in dynamic mode?
In dynamic mode, developers must set field values in the specific order they appear in the NetSuite user interface to ensure correct sourcing and validation. This mimics the real-time behavior seen in the UI.
Which operations can be performed with the record methods available in SuiteScript 2.x?
Using SuiteScript 2.x, you can perform operations such as creating new records with `record.create(options)`, duplicating records with `record.copy(options)`, accessing specific records by ID with `record.load(options)`, and transforming one record type into another with `record.transform(options)`. Each operation can be used in either standard or dynamic mode, as needed.
Source: Syntax Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →