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:

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

Note:

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, location or customlist_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);
}); 

            

Related Topics

General Notices