In a saved search, I'm including "Billing Address ...
# suitescript
m
In a saved search, I'm including "Billing Address : Internal ID" which gives me a number. When I try to update the
billaddresslist
field on a transaction for the same customer, that value doesn't work. The IDs that the
billaddresslist
field is expecting are different, as seen with
field.getSelectOptions()
. How can I map the "Internal ID" of an address to the value expected for
billaddresslist
? SuiteQL, N/search, Load customer record and scan addresses? Is there a ay to do this?
b
you want to learn the difference between the id of the address subrecord and the id of the addressbook line
m
@battk You are correct. That's what I want to learn. 🙂 I'm writing a script that needs to update the bill/ship addresses on sales orders. The source data for this script is a transaction saved search. As an example, the search output for a transaction has 413678 as the "Billing Address : Internal ID". When I look at a transaction with that address, the value in the 'billaddresslist' is 409361. I'm struggling to find the relationship between these values. Can I add the "id of the address subrecord" to the results of the saved search? If not, what connects the "id of the addressbook line" to the "id of the address subrecord"?
b
wrong search, the transaction search doesnt expose the addressbook id
load your customer in script and inspect the addressbook lines
then get the address subrecord to get its id
after that you should be able to figure out how to do the entity search
s
if you're updating custom addresses on SOs why not just do so through the
shippingaddress
or
billingaddress
subrecords?
m
Thanks, @battk. The transaction search is telling me which transactions need to be updated. The idea is that these transactions already have an address that is selected from the customer. We want to change the customer on that transaction which means we need a new address so we're adding a custom address. The requirements ask us to be able to roll back these changes so if we change the customer back to the original customer, I wanted to put the original address back in by selecting it. It would definitely be easier to just add the original address back as a custom address as @Shawn Talbert suggested. Thanks, guys!