Field.getSelectOptions(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Obtains an array of available options on a dropdown select, multi-select, or radio field.

The internal ID and label of the field options are returned as name/value pairs.

Returns

Object[]

This function returns an array in the following format:

                    [{value: 5, text: 'abc'},{value: 6, text: '123'}] 

                  

This function returns Type Error if the field is not a supported field for this method.

If you attempt to get select options on a field that is not a dropdown select field, such as a popup select field or a field that does not exist on the form, null is returned. For example, if the number of options available for the field is greater than your setting for Maximum Entries in Dropdowns at Home > Set Preferences, the field becomes a popup field, and this method returns null.

Because the maximum value for the Maximum Entries in Dropdowns settings is 500, the maximum number of options that can be returned by this method is 500.

Note:

A call to this method may return different results for the same field for different roles.

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

string

optional

A search string to filter the select options that are returned. For example, if there are 50 select options available, and 10 of the options contains 'John', for example, “John Smith” or “Shauna Johnson”, only those 10 options will be returned.

Filter values are case insensitive. The filters 'John' and 'john' will return the same select options.

2015.2

options.filteroperator

string

optional

Supported operators are contains | is | startswith.

If not specified, defaults to the contains operator.

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 : 'a',
    text : 'Albert'
});
var options = field.getSelectOptions({
    filter : 'a',
    filteroperator: 'startswith'
});
...
//Add additional code 

        

Related Topics

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

General Notices