Field.addSelectOption(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Adds the select options that appears in the dropdown of a field.

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.

Returns

void

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.value

string

required

The internal ID of this select option.

2015.2

options.text

string

required

The label for this select option.

2015.2

options.isSelected

Boolean

optional

If set to true, this option is selected by default in the UI. The default value for this parameter is false.

2015.2

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 selectField = form.addField({
    id : 'custpage_selectfield',
    type : serverWidget.FieldType.SELECT,
    label : 'Select'
});

selectField.addSelectOption({
    value : '',
    text : ''
});

selectField.addSelectOption({
    value : 'a',
    text : 'Albert'
});
...
//Add additional code 

        

Related Topics

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

General Notices