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.
Source: This article is based on Oracle's official NetSuite documentation.
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 Administration
- Unlimited Sandbox Refreshes in NetSuite 2026.1
Starting in NetSuite 2026.1, sandbox accounts can be refreshed an unlimited number of times, enhancing testing capabilities.
- Administration Enhancements in NetSuite 2026.1
Updates in NetSuite 2024.1 enhance Administration SuiteApps, continuing refinements from 2026.1.
- Create Integration Records for OAuth 2.0 in NetSuite 2026.1
In NetSuite 2026.1, administrators can create integration records for applications to use OAuth 2.0, enabling secure access. Here's how.
- Prompt Studio: Generative AI Management in NetSuite 2026.1
Prompt Studio in NetSuite 2026.1 enhances generative AI management, enabling customization of prompts and Text Enhance actions.
Advertising
Reach Administration Professionals
Put your product in front of NetSuite experts who work with Administration every day.
Sponsor This Category