Automatic Location Assignment Macro

The macro for automatic location assignment offers an additional way to assign fulfillment locations automatically. You can use the macro in a script to run the automatic location assignment engine in response to events that are not included with the Automatic Location Assignment (ALA) feature. See Business Events for more information about ALA events. To run the macro in a script, the Automatic Location Assignment feature must be enabled and configured correctly.

Usage of macros in NetSuite requires SuiteScript 2.0 — see Overview of Record Action and Macro APIs for more information.

The following example script shows how to use the autoAssignLocations macro on a sales order record object when it is the current record.

          // Use the autoAssignLocations macro to assign locations automatically on the current record.
require(['N/currentRecord'], function(currentRecord) {
    var salesOrder = currentRecord.get();
    salesOrder.executeMacro({id: 'autoAssignLocations'});    
}); 

        

When the macro runs and a location is assigned to a sales order line, the sales order is counted towards the AOM automation capacity of your account. If a location is not assigned to a sales order line, the sales order is not counted towards AOM automation capacity. See Automation Capacity and Usage Fees for more information about usage limits and fees.

A script that calls the autoAssignLocations macro runs independently of the settings on the Advanced Order Management Setup page in NetSuite. This means that if the Run Automation box is not checked or a predefined business event is not selected, the macro runs regardless. For example, if you clear the Sales Order Approved box on the Advanced Order Management Setup page, you can still create a script that calls the autoAssignLocations macro when a sales order is approved. Likewise, if you clear the Run Automation box for shipping orders, a script that calls the macro will still run the automatic location assignment process.

Note:

The autoAssignLocations macro is callable in a script in your NetSuite account even if the Automatic Location Assignment feature is not enabled. If you try to run the macro without enabling the feature, however, it returns an error.

Return Values

The macro returns a different set of values depending on whether automatic location assignment ran successfully or an error occurred. Note that automatic location assignment might run successfully but not assign a location to a sales order.

          var runAutomaticLocationAssignment = salesOrder.executeMacro({id: 'autoAssignLocations'});

// If automatic location assignment runs successfully, it returns an object similar to the following, with the 'notifications' and 'response' properties:
{
    notifications: [{title: 'DONE'; message: 'Automatic Location Assignment executed.'}],
    response: {assignedLines: [0,1]}
}

// If automatic location assignment fails, it returns an object with an 'error' property:
{
    error: 'Text of error message from automatic location assignment engine.'
} 

        

Known Limitations

The macro does not currently support running both advanced order management (AOM) automation processes (automatic location assignment and fulfillment request creation) in sequence. This means that even if you automate creation of fulfillment requests (on the Advanced Order Management Setup page), the system will not create fulfillment requests after the autoAssignLocations macro runs. If you want fulfillment requests to be created after automatic location assignment has run, you must configure automatic location assignment on the Advanced Order Management Setup page.

Related Topics

General Notices