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.

·2 min read·View Oracle Docs

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:

PropertyAvailability
Field.idStandard and dynamic modes
Field.isDisplayDynamic mode only
Field.isMandatoryStandard and dynamic modes
Field.labelStandard and dynamic modes
Field.sublistIdDynamic mode only
Field.typeStandard 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:

suitescript
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 action
17}
18if(objField.type === 'checkbox'){
19 // Perform an action
20}
21...
22// Add additional code

This 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?
In SuiteScript 2.x, you can use methods like Record.getField(options), Record.getSublistField(options), Record.getCurrentSublistField(options), CurrentRecord.getField(options), and CurrentRecord.getSublistField(options) to access Field objects.
Are Field objects accessible in both client and server-side scripts?
Yes, Field objects can be accessed in both Client and Server Side scripts in SuiteScript 2.x, allowing for versatile programming options within NetSuite.
What Field object properties are available in dynamic mode only?
In dynamic mode, the properties Field.isDisplay and Field.sublistId are available.
What permissions are required to use Field objects in SuiteScript 2.x?
The article does not specify permissions required for using Field objects in SuiteScript 2.x. It would be prudent to refer to specific script type documentation for permissions details.
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 Administration

View all Administration articles →