Redirect a New Sales Order

The following sample shows how to use a Suitelet to redirect to a new sales order record and set the entity field (which represents the customer).

Note:

This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.

Important:

The value used in this sample for the entity field is a placeholder. Before using this sample, replace the entity field value with a valid value from your NetSuite account. If you run a script with an invalid value, an error may occur.

          /**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */

// This script redirects a new sales order record and sets the entity.
define(['N/record', 'N/http'], (record, http)=> {
    function onRequest(context) {
        context.response.sendRedirect({
            type: http.RedirectType.RECORD,
            identifier: record.Type.SALES_ORDER,
            parameters: ({
                entity: 6
            })
        });
    }
    return {
        onRequest: onRequest
    };
}); 

        

Related Topics

SuiteScript 2.x Suitelet Script Type
SuiteScript 2.x Suitelet Script Type Code Samples
Backend Suitelets
N/http Module
N/record Module

General Notices