getOrderData()

The getOrderData() function (client-side and server-side) retrieves body and sublist field values belonging to the transaction page from which users open the product. The transaction must be available for NetSuite CPQ Configurator. For more information about compatible transactions, see Selecting Eligible Transactions.

Note:

To retrieve current information from the transaction page as entered by users, enable Submit to transaction page on the options record. If this option isn't enabled, data is retrieved from the transaction record saved in the database using getData(). Information retrieved this way may not include the latest information provided by users.

Syntax

Use these syntax formats for the getOrderData() function:

  • To retrieve body and sublist fields for compatible transactions:

                    getOrderData({
        fields: ['fieldId1', 'fieldId2', ..., 'fieldIdn'],
        sublists: {
            sublistId1: ['fieldId1', 'fieldId2', ..., 'fieldIdn']
        }
    }).done(callback); 
    
                  
  • To retrieve body and Items sublist fields for compatible transactions:

                    getOrderData({
        fields: ['fieldId1', 'fieldId2', ..., 'fieldIdn'],
        columns: ['fieldId1', 'fieldId2', ..., 'fieldIdn']
    }).done(callback); 
    
                  

To retrieve information for multiple sublists, including the Items sublist, use the sublists property.

Return Value

The getOrderData() function returns a promise that resolves to an object containing the requested transaction body and sublist fields.

Parameters

Note:

All properties are optional.

The getOrderData() function accepts an object as a parameter. The object includes the following properties:

  • fields - An array of field IDs to specify the fields to return.

    Results for dropdown lists, multi-select fields, and image fields return the internal ID of the selected option or image. To get the selected option label or the image relative URL in the File Cabinet, add the :text suffix to the field ID. For example, 'location:text' will give you the location's name, such as, San Francisco.

    To retrieve the field label, add the :label suffix to the field ID. For example, 'location:label' returns Location.

  • sublists - An object in which each key represents the ID of a sublist to return. For each sublist, the value is an array of field IDs to retrieve from that sublist. You can add the :text suffix to sublist field IDs.

  • columns - An array of sublist field IDs to specify the sublist fields to return for the Items sublist on compatible transactions. You can add the :text suffix to field IDs.

Examples

The following examples show how to use the getOrderData()) function.

Retrieving Body and Sublist Fields for a Transaction

This example shows how to request specific transaction body fields as well as fields from the Items sublist on the sales order. The callback logs the data to the console.

              getOrderData({
    fields: ['tranid', 'entity:label', 'location:text'],
    sublists: {
        item: ['item', 'quantity', 'rate', 'amount']
    }
}).done(function(data) {
    console.log('Data', data);
}); 

            

This second example performs the same task but using the columns property.

              getOrderData({
    fields: ['tranid', 'entity:label', 'location:text'],
    columns: ['item', 'quantity', 'rate', 'amount']
}).done(function(data) {
    console.log('Data', data);
}); 

            

Related Topics

General Notices