Field Object Syntax in SuiteScript 2.x Programming
Understand the syntax for accessing Field objects in SuiteScript 2.x to interact with standard and custom records.
TL;DR Opening: This article explains the syntax for working with Field objects in SuiteScript 2.x, crucial for developers building scripts to manipulate record fields on standard and custom records.
What is the Field Object?
The Field object represents a body or sublist field associated with a record, enabling developers to access detailed field properties and perform actions based on them. Accessing this object can be done through a variety of methods depending on whether you're working within record scripts or client scripts.
Methods to Access Field Objects
You can use the following methods to interact with Field objects in SuiteScript 2.x:
Record.getField(options): Access a standard or custom body field from a record.Record.getSublistField(options): Retrieve a field from a specified sublist.Record.getCurrentSublistField(options): Obtain a current line field value from a sublist.CurrentRecord.getField(options): Access a field from the current record context.CurrentRecord.getSublistField(options): Get a field from the current sublist.
Field Properties
Several properties of the Field object are critical for determining how fields behave, especially in different modes:
| Property | Availability |
|---|---|
Field.id | Standard and dynamic modes |
Field.isDisplay | Dynamic mode only |
Field.isMandatory | Standard and dynamic modes |
Field.label | Standard and dynamic modes |
Field.sublistId | Dynamic mode only |
Field.type | Standard and dynamic modes |
For a detailed understanding, refer to the documentation on record modes.
Supported Script Types
Field objects can be accessed in both Client and Server Side scripts, which allows for versatile programming options within NetSuite.
Example Syntax
The example below illustrates how to access a Field object from a Sales Order record:
1// Add additional code 2...3var objRecord = record.load({4 type: record.Type.SALES_ORDER,5 id: 275 6});7 8var objSublist = objRecord.getSublist({9 sublistId: 'item' 10});11 12var objField = objSublist.getField({13 fieldId: 'item' 14}); 15if(objField.label === 'myLabel' ){ 16 // Perform an action17}18if(objField.type === 'checkbox'){ 19 // Perform an action20}21...22// Add additional codeThis snippet illustrates how to retrieve a sublist field and evaluate its properties.
Who This Affects
- Developers: Those building custom SuiteScripts will find this information essential for effective programming.
- Administrators: Understanding how fields are accessed can aid in troubleshooting and customization.
Key Takeaways
- The Field object is essential for interacting with records in SuiteScript 2.x.
- Accessing field properties can help developers write more dynamic scripts.
- Familiarity with various methods to obtain Field objects is crucial for efficient SuiteScript development.
Frequently Asked Questions (4)
What methods can be used to access Field objects in SuiteScript 2.x?
Are Field objects accessible in both client and server-side scripts?
What Field object properties are available in dynamic mode only?
What permissions are required to use Field objects 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.
