Rosse's Profile
Rookie
7
Points

Questions
1

Answers
2

  • Rookie Asked on October 4, 2019 in SuiteScript.

    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; 
    }
    • 2483 views
    • 3 answers
    • 0 votes
  • Rookie Asked on October 3, 2019 in SuiteScript.

    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?

     

    • 2483 views
    • 3 answers
    • 0 votes