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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category