Trying to get the address in a location record fro...
# suitescript
c
Trying to get the address in a location record from a IF (we use line level on IF but header on SO). I was able to do it with a lookupFields
var locationFields = search.lookupFields({
type: search.Type.LOCATION,
id: createdFrom,
columns: ['address.address']
});
but the results come back like this
Copy code
"address.address": "xxxxxx\r\xxxxxx xxxx Ave\r\nChicago IL xxxxx\r\nUnited States"
That's what gets set in the custom field. How do I just get the address part and not the whole string?
r
Why would createdFrom be a location? Isn't that usually for transactions?
Sounds like you're looking for
address1
? Or possibly
address1
and
address2
?
c
Ya but I want the whole address not to break it apart
c
To clarify this is on transaction.
r
Oh that makes sense. I was confused.
c
Ya so on my Invoice which has line level location, I want to pull the SO header level location address
So I'm doing a search to pull the created from location, now where I'm having weird result is pulling the whole address and not breaking it. I thought it would be addrtext but it doesnt work
r
Addresses are subrecords, usually subrecords on a sublist line. It doesn't matter when you perform a search, but if you want only address1, 2, and 3 or similar, you either need to get the individual fields and format them yourself or do some string manipulation to remove the city, state, etc.
c
right but I want the whole block
r
Use string concatenation or or extract a substring.
👍 1