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.
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:
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/recordmodule is essential for effective scripting.
Frequently Asked Questions (4)
How can I enable dynamic mode when loading a record in SuiteScript 2.x?
What is the key advantage of using standard mode for record operations in SuiteScript 2.x?
What should developers keep in mind when setting field values in dynamic mode?
Which operations can be performed with the record methods available in SuiteScript 2.x?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
