Hello everyone, I'm building Restlets that allow u...
# suitescript
m
Hello everyone, I'm building Restlets that allow users to get, add, and update addresses in the Customer sublists. The problem I'm having is if I pull the sublist subrecord, I get different values than if I pull the address all by itself. What's the best approach to handling addresses in a sublist?
b
General answer is use the subrecord
That said, what differences are you seeing
m
So the biggest difference is the address id. With the sub record it's the line id associated to the customer address line, and the record has a completely different id. Also, some of the fields aren't in the payload when I pull the subrecord, like addr1
b
All the address fields should be on the subrecord
Dont confuse the internal id with the address internal id
m
Ok, so not to sounds like an idiot, but here's the call I'm making: var customer = record.load({ type: record.Type.CUSTOMER, id: 19979 }); return customer.getSublistSubrecord({ sublistId: "addressbook", fieldId: "addressbookaddress", line: 0 }); this returns an address with an id of 23242, but if I do this: return customer.getSublistValue({ sublistId: "addressbook", fieldId: "id", line: 0 }); this returns an Id of 18941 This causes a problem for me when I'm trying to update an existing address, because I use the findSublistWithValue({ sublistId: "addressbook", fieldId: "id", value: ID }); One of the above values gives me the right line number and the other comes back with -1. How do you update an existing address the right way?
b
thats the internal id vs address internal id thing
addresses have an address internal id and an internal id
they are different numbers
Copy code
customer.getSublistSubrecord({ sublistId: "addressbook", fieldId: "addressbookaddress", line: 0 }).getValue({fieldId: 'id'}) // this is the internal id
customer.getSublistValue({ sublistId: "addressbook", fieldId: "addressbookaddress", line: 0 }) // this is also internal id if you really want to use sublist fields
Copy code
customer.getSublistValue({ sublistId: "addressbook", fieldId: "id", line: 0 }) // this is the address internal id
use the matching id depending on whatever id is your input
keep in mind that suitescript uses internal id in select fields while netsuite uses the address internal id while displaying ids in the ui