Setting Values with SuiteScript Current Record Module
SuiteScript's currentRecord module allows developers to set field values for records efficiently using various parameter types.
TL;DR Opening
The currentRecord module in SuiteScript allows developers to set the value of specific fields on records easily. It supports various parameter types for different field types, streamlining record management in NetSuite.
Method Description
The setValue method within the currentRecord module is crucial for setting field values in records. This function supports numeric values, Date instances, conditional booleans, and other data types, thereby enabling efficient record manipulation, especially during client-side operations.
Supported Script Types
- Client scripts
For more detailed script type information, refer to the SuiteScript 2.x Script Types.
Parameters
The options parameter is a JavaScript object containing the following properties:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.fieldId | string | required | The internal ID of the field (standard or custom). For details, refer to Finding Internal IDs of Record Fields. |
options.value | number | Date | string |
- Text, Radio, Select, and Multi-Select fields take string values.
- Checkbox fields require boolean values.
- Date and DateTime fields utilize Date objects.
- Integer, Float, Currency, and Percent fields take numeric values.
|
options.ignoreFieldChange| boolean | optional | If set totrue, any field change and associated events are ignored. Defaults tofalse. | |options.forceSyncSourcing| boolean | optional | If set totrue, dependent field information is sourced synchronously. This can help ensure that field sourcing completes before APIs are triggered, which can prevent improper results in some browsers. Defaults tofalse.
Errors
When using the setValue method, the following error codes may be encountered:
INVALID_FLD_VALUE: Thrown if theoptions.valuedoes not match the required field type.SSS_MISSING_REQD_ARGUMENT: Indicates that a required argument is not provided or undefined.
Syntax
Here’s a basic syntax illustration utilizing the setValue method. This is not a complete functional example; please refer to the relevant module scripts for full samples.
1//Add additional code 2...3objRecord.setValue({4 fieldId: 'item',5 value: true,6 ignoreFieldChange: true,7 forceSyncSourcing: true8});9...10//Add additional codeRelated Topics
- currentRecord.CurrentRecord
- N/currentRecord Module
- SuiteScript 2.x Modules
- SuiteScript 2.x
Who This Affects
This information is primarily useful for:
- Developers
- Client script authors
- NetSuite administrators involved in record management
Key Takeaways
- The
setValuemethod allows effective management of field values through various data types. - Parameters must correspond correctly with expected field types to prevent errors.
- Synchronous sourcing can alleviate timing issues in browsers, ensuring reliable data handling.
Frequently Asked Questions (4)
Can you use the currentRecord module's setValue method in server-side scripts?
What happens if you do not provide the required options.fieldId when using setValue?
What data type should be used for Date fields when setting values using the setValue method?
Does the ignoreFieldChange parameter default to true in the setValue method?
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.
