Scripting Transaction Shipping and Billing Addresses

A transaction’s shipping address is stored in an address subrecord referenced from a body field on the transaction. A transaction’s billing address is stored in the same way. The process of interacting with these subrecords is similar to how you work with other subrecords referenced by body fields. However, some differences exist. For details, see the following sections:

Note:

See also About the Address Subrecord.

Addresses Can Be Sourced from Entity Records

Many transactions are associated with an entity. The entity record may already have addresses defined on its Address subtab. When working with a transaction, you can designate one of these existing addresses as the transaction’s shipping or billing address.

If you choose to reference an existing address, your script does not have to create an address subrecord or use any subrecord methods. Instead, you can pick an address with a select field that is associated with the summary field. For example, to designate an existing address as the shipping address on a sales order, you use the shipaddresslist select field. This field identifies the subrecord being used by the transaction’s shippingaddress summary field. For an example of how to select an existing address using the shipaddresslist select field, see Using SuiteScript 2.x to Select an Existing Shipping Address Example.

A Default Address May Be Used

An entity can have a default shipping or billing address. For these types of entities, if you create a transaction and you don’t set a value for shipping or billing address, the entity’s default is used.

If the entity has a default shipping or billing address that you want to completely override, use removeSubrecord() to clear the summary field before you set the values for your new subrecord. As an alternative, you can set the shipaddresslist field to null before setting your new address values. For an example, see Using SuiteScript 2.x to Create a New Shipping Address Example.

New Shipping and Billing Addresses Are Always Custom

In the UI, if you are creating a sales order and you want to enter a new shipping address, you must select either New or Custom in the Ship to Select field. If you select New, the address you enter is also saved to the customer record. If you select Custom, the new address is not saved to the customer record. It is saved only on the transaction.

By contrast, in SuiteScript, you cannot choose between New or Custom. Any new shipping or billing address created by your script is treated as a Custom address. The address is saved on the transaction, but it cannot be saved to the entity record.

Related Topics

Scripting Subrecords that Occur in Body Fields
Using SuiteScript 2.x to Create a Body Field Subrecord
Using SuiteScript 2.x to Update a Body Field Subrecord
Using SuiteScript 2.x to Retrieve a Body Field Subrecord

General Notices