ANS-1150 · SUITESCRIPT DEVELOPMENT

How to Override the Default Shipping Address on a NetSuite Sales Order with SuiteScript?

Learn how to programmatically clear the default shipping address selection on a Sales Order in NetSuite using SuiteScript before populating individual address fields.

Short answer

To override the default shipping address on a NetSuite Sales Order via SuiteScript, first clear the existing selection. This ensures that individual address fields can be populated independently. Use the SuiteScript function salesorder.setFieldValue('shipaddresslist', null); to achieve this, allowing custom address details to be applied without conflict.

Scenario

NetSuite users often encounter situations where they need to programmatically set a custom shipping address on a Sales Order using SuiteScript. A common challenge arises when a default shipping address is already selected on the Sales Order, preventing individual address fields from being updated as intended. This occurs because the individual address fields are dependent on the 'Shipping Address' select field.

Solution

To successfully override the default shipping address on a Sales Order using SuiteScript, it is crucial to first clear any pre-selected shipping address. The individual shipping address fields operate independently of the 'Shipping Address' select field. Therefore, before attempting to set specific address details, the default selection must be explicitly removed. This can be accomplished by setting the shipaddresslist field to null using the following SuiteScript function:

salesorder.setFieldValue('shipaddresslist', null);

Once the default selection is cleared, individual shipping address fields can then be populated programmatically without conflict.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant