setValue Method for SuiteScript CurrentRecord Object

The setValue method allows you to set field values on the current record in SuiteScript, essential for dynamic data handling.

·2 min read·View Oracle Docs

The setValue method is a crucial part of the SuiteScript currentRecord module, enabling developers to programmatically set values for various record fields. This capability is particularly useful for client scripts where dynamic user inputs are required.

Method Description

The setValue method sets the value of a specified field on the current record. This method allows for various types of fields, including numeric, string, date, and boolean types.

Returns

The method returns the currentRecord.CurrentRecord object, allowing further manipulation of the record.

Supported Script Types

This method is applicable in Client scripts. For details on supported script types, refer to the SuiteScript 2.x Script Types.

Governance

There are no specific governance limits for this method.

Parameters

The setValue method accepts an object as its parameter. Each property of this object has specific requirements:

ParameterTypeRequired / OptionalDescription
options.fieldIdstringrequiredThe internal ID of a standard or custom body field. For more details, see Finding Internal IDs of Record Fields.
options.valuenumber, Date, string, array, booleanrequiredThe value you want to set. This value must match the type of the field being set. For instance, string values for text fields, and boolean for checkboxes.
options.ignoreFieldChangebooleanoptionalIf set to true, it ignores any field change events that would typically follow. By default, this is set to false.
options.forceSyncSourcingbooleanoptionalWhen set to true, it forces synchronous sourcing of dependent fields. This can help mitigate timing issues in certain browsers when handling events. Defaults to false.

Errors

The setValue method may throw the following errors:

  • INVALID_FLD_VALUE: Triggered when the options.value type does not correspond with the targeted field type.
  • SSS_MISSING_REQD_ARGUMENT: Triggered if any required arguments are either missing or undefined.

Syntax

Here’s a basic syntax example demonstrating the setValue method:

suitescript
1//Add additional code
2...
3objRecord.setValue({
4 fieldId: 'item',
5 value: true,
6 ignoreFieldChange: true,
7 forceSyncSourcing: true
8});
9...
10//Add additional code

Conclusion

Understanding how to utilize the setValue method effectively allows for more dynamic and interactive forms within NetSuite's scripting environment. Ensure to review the types of values that can be set based on field type to avoid errors during implementation.

Frequently Asked Questions (4)

Is the setValue method available in all NetSuite script types?
No, the setValue method is applicable in Client scripts as described in the document.
What happens if I provide a value that does not match the field type when using setValue?
If the options.value type does not correspond with the targeted field type, an INVALID_FLD_VALUE error will be triggered.
Do I need to be concerned about governance limits when using the setValue method?
No, there are no specific governance limits for the setValue method.
Can I prevent field change events when using the setValue method?
Yes, by setting the options.ignoreFieldChange parameter to true, you can ignore any field change events that would typically follow the method's execution.
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 →