Field Value Setting in SuiteScript 2.0 with N/record Module
Learn to set field values using the N/record module in SuiteScript 2.0. Understand data types and field order importance.
Setting field values is crucial for effective record management in SuiteScript 2.0, utilizing the N/record module. This article explains how to correctly set values for different field types, ensuring accurate data entry and manipulation.
What is Setting Field Values?
Setting the value of a field is a foundational operation in SuiteScript 2.0. This can be done in both dynamic and standard modes. Understanding these modes is crucial as they influence how field values are handled during scripting operations.
Dynamic vs Standard Mode
- Standard Mode: Field values are processed in an abstract manner and validated upon saving the record. There’s no need to set fields in a specific order.
- Dynamic Mode: This mode behaves like the NetSuite UI, requiring careful attention to the order of field settings. Setting fields incorrectly could lead to overridden values, impacting the script’s behavior.
Method Description
The primary method of setting a field value is via the setValue(options) function in the N/record module. This method takes an options object, allowing for flexibility in what is set.
Parameters for setValue(options)
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.fieldId | string | Required | The internal ID of the field you want to set. |
options.value | number | Date | string |
options.ignoreFieldChange | boolean | Optional | If true, ignores the field change and secondary event triggered by it. Default is false. |
Supported Value Types
- Text and Radio fields accept
stringvalues. - Select fields can accept both
stringandnumbervalues. - Multi-Select fields require an
arrayof values. - Checkbox fields accept
booleanvalues. - Date fields should be assigned
Datevalues. - Numeric fields (
Integer,Float,Currency,Percent) acceptnumber. - Inline HTML field values must be provided as
strings, which are processed as HTML entities.
Error Handling
When setting values, it’s important to be aware of potential errors that may arise.
INVALID_FLD_VALUE: This error indicates a mismatch between the type of the value being set and the field type.SSS_MISSING_REQD_ARGUMENT: This error occurs when a required parameter is missing or undefined.
Code Samples
The following code demonstrates how to use setValue() to set a field and what to expect when working with INLINEHTML fields.
Standard Setting Value Example
1// Add additional code 2... 3objRecord.setValue({ 4 fieldId: 'item', 5 value: true, 6 ignoreFieldChange: true 7}); 8... 9// Add additional code Inline HTML Field Example
... objRecord.setValue(inlineHtmlFieldId, '<i>foo</i>'); // Returns text in cursive. objRecord.getValue(inlineHtmlFieldId); // Returns '<i>foo</i>' objRecord.getText(inlineHtmlFieldId); // Returns 'foo' ... This foundational knowledge is essential for successful scripting in NetSuite, ensuring that field values are handled correctly as business processes demand.
Who This Affects
- Developers working with SuiteScript 2.0
- Administrators managing or customizing NetSuite records
- Technical Users involved in integrations and custom applications
Key Takeaways
- Setting field values correctly is essential for data accuracy.
- Distinguish between dynamic and standard script modes to prevent value overrides.
- Understand the specific value types required for different field types.
- Implement error handling for robust scripts.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
How does dynamic mode differ from standard mode when setting field values?
What types of values can be assigned to different fields using setValue()?
What are common errors encountered when setting field values?
Is it possible to ignore field change events when setting field values in SuiteScript 2.0?
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.
- Custom Tool Script Enhancements in NetSuite
Custom tool scripts in NetSuite gain execution log support and a new management page in February 16, 2026.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- 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.
