How could we get formatted string of shipping addr...
# suitescript
b
How could we get formatted string of shipping address from Sales Order?
s
try
so.shippingaddress.addrtext
(NFT)
c
I was dealing with something similar recently - Needed to compare ship-to addresses in a saved search by their actual addresses and not internal ids. I wound up creating a custom field, and a UE script to populate that field:
Copy code
function afterSubmit(context) {
    var invoice = record.load({
        type: record.Type.INVOICE,
        id: context.newRecord.id,
        isDynamic: true
    })
    var shippAddrSubRecord = invoice.getSubrecord('shippingaddress')
    var shipAddr1 = shippAddrSubRecord.getText({
        fieldId: 'addr1'
    })
    var shipAddr2 = shippAddrSubRecord.getText({
        fieldId: 'addr2'
    })
    var shipAddr3 = shippAddrSubRecord.getText({
        fieldId: 'addr3'
    })
    var shipCity = shippAddrSubRecord.getText({
        fieldId: 'city'
    })
    var shipState = shippAddrSubRecord.getText({
        fieldId: 'state'
    })
    var shipZip = shippAddrSubRecord.getText({
        fieldId: 'zip'
    })
    var shipAddrText = shipAddr1 + '\n' + shipAddr2 + '\n' + shipAddr3 + '\n' + shipCity + '\n' + shipState + '\n' + shipZip
    invoice.setValue({
        fieldId: 'custbody_ship_address_text',
        value: shipAddrText
    })
    invoice.save()
}