getFieldOptions()
The getFieldOptions() function (server-side) retrieves all options for a NetSuite body dropdown list or multi-select field, or retrieves all options for a standard or custom NetSuite list. This function supports retrieving up to 4,000 results.
To improve performance:
-
If a dropdown list or a multi-select field is linked to a NetSuite list for its options, retrieve the options directly from the list.
-
If a dropdown list or a multi-select field isn't linked to a NetSuite list and it references records instead, determine the record type and use
getData()to retrieve the options.
Syntax
These syntax formats are available for the getFieldOptions() function:
-
To retrieve options for a specific NetSuite field, use:
getFieldOptions('recordType', 'fieldId').done(callback); -
To retrieve options for a NetSuite list, use:
getFieldOptions('listId').done(callback);
Return Value
The function returns a promise that resolves to an object or an array of objects with key-value pairs that represents option values and their labels. The returned object has the following structure:
{
"internalId1": "label1",
"internalId2": "label2",
"internalId3": "label3",
"internalId4": "label4"
...
}
Parameters
The record type is required.
The getFieldOptions() function accepts the following parameters:
-
recordType(string) - Specifies the type of the record from which to retrieve options, for example,inventoryitem. -
fieldID(string) - Specifies the ID of the dropdown list field from which to retrieve options, for example,class. -
listId(string) - Specifies the Internal ID of the NetSuite list to retrieve, for example,locationorcustomlist_scpq_list_answer_datatype.
Examples
The following examples show how to use the getFieldOptions() function.
Retrieving All Options for a Specific Field
This example retrieves all options for the class field on the inventory item record.
getFieldOptions('inventoryitem', 'class').done(function(rdata) {
console.log('Done', rdata);
});
Retrieving All Options for a NetSuite List
This example retrieves all options from the classification list.
getFieldOptions('classification').done(function(rdata) {
console.log('Done', rdata);
});