Form.addField(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Adds a field to a form.

Returns

serverWidget.Field object

Supported Script Types

SuiteScript 2.x Suitelet Script Type and SuiteScript 2.x User Event Script Type (beforeLoad(context))

Governance

None

Module

N/ui/serverWidget Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.id

string

required

The internal ID of the field.

The internal ID must be in lowercase, contain no spaces, and include the prefix custpage if you are adding the field to an existing page. For example, if you add a field that appears as Purchase Details, the field internal ID should be something similar to custpage_purchasedetails or custpage_purchase_details.

2015.2

options.label

string

required

The label for this field.

2015.2

options.type

string

required

The field type for the field. Use the serverWidget.FieldType enum to define the field type.

Important:

Long text fields created with SuiteScript have a character limit of 100,000. Long text fields created with Suitebuilder have a character limit of 1,000,000.

2015.2

options.source

string

optional

The internalId or scriptId of the source list or record type for this field if it is a select (List/Record) or multi-select field.

Source list is a category containing standard lists and custom lists. Record types include standard record types like employee, sales order, and transaction, as well as custom record types.

Examples of IDs include: standard record (salesorder, customer, employee); custom record (customrecord_car_model); standard list: (employeetype, ordertype); custom list (customlist_color).

Important:

After you create a select or multi-select field that is sourced from a record or list, you cannot add additional values with Field.addSelectOption(options). The select values are determined by the source record or list.

Note:

For radio fields only, the source parameter must contain the internal ID for the field. For more information about working with radio buttons, see SuiteScript 1.0 Documentation.

2015.2

options.container

string

optional

The internal ID of the tab or field group to add the field to.

By default, the field is added to the main section of the form.

2016.1

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/ui/serverWidget Module Script Samples.

          //Add additional code 
...
var form = serverWidget.createForm({
    title : 'Simple Form'
});
var field = form.addField({
    id : 'custpage_abc_text',
    type : serverWidget.FieldType.TEXT,
    label : 'Text'
});
...
//Add additional code 

        

Related Topics

serverWidget.Form
N/ui/serverWidget Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices