Figured it out! For those lost souls who venture here in the future:
Below is a function you can use on a sales order line level to loop through the custom addresses and pull out specific information.
Hopefully, this will be added to the NetSuite documentation at some point.
Note that I was doing this specifically for the state information. If you want to see what other fields are available, add &xml=T
to the end of a submitted sales order URL and search for iladdrbook
in the resuling xml structure. It is actually treated like a line item.
function getCustomAddressFromLineItem(soLineNum) {
nlapiLogExecution('DEBUG', 'Custom Address', 'Custom Address: Line # ' + soLineNum);
var addressid = nlapiGetLineItemValue('item','shipaddress',soLineNum); // get the id of the custom address
var customAddressesLineCount = nlapiGetLineItemCount('iladdrbook'); // get custom address book count
nlapiLogExecution('debug', 'test', 'addressid: ' + addressid + ' -- linecount: ' + customAddressesLineCount);
for (var i = 1; i <=customAddressesLineCount; i++)
{
var addressinternalid = nlapiGetLineItemValue('iladdrbook','iladdrinternalid',i); // get internal id of custom address book
if (addressinternalid == addressid) // match it with the id of custom address being set
{
var addr = nlapiGetLineItemValue('iladdrbook','iladdrshipaddr1',i);
var customState = nlapiGetLineItemValue('iladdrbook','iladdrshipstate',i); // get your state
nlapiLogExecution('debug', 'test', 'address: ' + addr + ' -- state: ' + customState);
return customState;
}
}
}