How to fetch “Custom” Address from a Multiple Shipping Routes enabled Sales Order?

I have Multiple Shipping Routes enabled Sales Orders and I am not able to fetch the address fields from the item line, when the address is a Custom one which is not saved in the entity record.

Has anyone done this?

Rookie Asked on October 2, 2019 in SuiteScript.
Add Comment
3 Answer(s)

Get the shippingaddress subrecord on the item sublist to access fields on the address.

https://system.na0.netsuite.com/app/help/helpcenter.nl?fid=section_4087199684.html#bridgehead_4769030318

NetSuite’s examples are more geared towards setting the address subrecord, but there are the equivalent get methods on the subrecord as well.

Advanced Answered on October 3, 2019.

You may actually want to submit a support case for this one. I was only able to get information from the subrecord on edits and not create.

on October 3, 2019.
Add Comment

Thanks for your response!

I need to fetch the custom address fields on before submit event on the sales order.
I am getting the internal id of the address using the following function.

nlapiGetLineItemValue('item', 'shipaddress', i);

I can also get the address text by accessing the shipgroup sublist:

nlapiGetLineItemValue('shipgroup', 'destinationaddress', 1);

I tried

nlapiViewLineItemSubrecord('item','shippingaddress', 1 )
  which is returning null.

I do not see any get functions listed in the documentation.

Would you provide the get function to get the address fields from the subrecord?

 

Rookie Answered on October 3, 2019.
Add Comment

You can use the iladdrbook sublist to fetch the addresses.

/*
 * Function to get all shipAddresses from a transaction including Custom Addresses
 */ 
function getMultiShipAddresses () { 
    var multiShipAddresses = []; 
    for (var ilAddrIdx = 1; ilAddrIdx<= nlapiGetLineItemCount(‘iladdrbook’); ilAddrIdx++){
        var shipAddressObj ={};
        shipAddressObj.internalid = nlapiGetLineItemValue(‘iladdrbook’, ‘iladdrinternalid’, ilAddrIdx); 
        shipAddressObj.addr1 = nlapiGetLineItemValue(‘iladdrbook’, ‘iladdrshipaddr1’, ilAddrIdx); 
        shipAddressObj.city = nlapiGetLineItemValue(‘iladdrbook’, ‘iladdrshipcity’, ilAddrIdx); 
        shipAddressObj.state = nlapiGetLineItemValue(‘iladdrbook’, ‘iladdrshipstate’, ilAddrIdx); 
        shipAddressObj.zip = nlapiGetLineItemValue(‘iladdrbook’, ‘iladdrshipzip’, ilAddrIdx); 
        shipAddressObj.country = nlapiGetLineItemValue(‘iladdrbook’, ‘iladdrshipcountry’, ilAddrIdx);   
        nlapiLogExecution(‘DEBUG’, ‘getMultiShipAddresses’,
                ‘shipAddressObj.internalid: ‘+shipAddressObj.internalid +
                ‘shipAddressObj.addr1: ‘+shipAddressObj.addr1 +
                ‘shipAddressObj.city: ‘+shipAddressObj.city +
                ‘shipAddressObj.state: ‘+shipAddressObj.state +
                ‘shipAddressObj.zip: ‘+shipAddressObj.zip +
                ‘shipAddressObj.country: ‘+shipAddressObj.country 
                 );
        if(shipAddressObj.internalid){
            multiShipAddresses[shipAddressObj.internalid] = shipAddressObj;
        }
    } 
    return multiShipAddresses; 
}
Rookie Answered on October 4, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor