How to get all the possible values that can be listed or accepted in the list field?

If we would like to get all the options listed in the list field or multi-select field in Netsuite we can utilize the “Field.getSelectOptions(options)” function available in the record module.

Using the method, we can obtain 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.

This function returns an array in the following format:

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

This function returns a 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: Client and server scripts

This function does not require any governance. So, we utilize it without any restrains.

ParameterstypeDescription
options.filterstringThe search string to filter the select options that are returned.Note Filter values are case insensitive.
options.operatorstringThe following operators are supported:contains (default),is, startswith

We can get the specific options available in the List field by using the filter and operator parameters. However, without setting any parameter will give us the full options listed in the listed field.

Sample code

var objRecord = record.load({
   type: record.Type.SALES_ORDER,
   id: 275
});

var objField = objRecord.getField({
   fieldId: 'couponcode'
});

var options = objField.getSelectOptions({
    filter : 'C',
    operator : 'startswith'
});

Leave a comment

Your email address will not be published. Required fields are marked *