How would you update a companies default billing a...
# suitescript
e
How would you update a companies default billing address? I tried loading the correct CUSTOMER record and changing
objRecord.setValue({ fieldId: 'billaddr1', value: 'NewValue' });
or
objRecord.setSublistValue({sublistId: 'addressbook', fieldId: 'addr1_initialvalue', line: 2, value: 'NewValue' });
and calling:
objRecord.save()
But I cant see the changes in NetSuites Address-tab
b
a customer's default billing address is on the addressbook line whose defaultbilling field is set to true
find out which line that is, get that lines address subrecord, and then do your updates to that subrecord
e
I use `findSublistLineWithValue`and see its line 2. When I save it looks like it has been saved. But when I go into NetSuite, the default billing address is not changed
b
what does your code look like
e
Copy code
var objRecord = record.load(
          { 
            type: record.Type.CUSTOMER,
            id: 2153
          });
        var lineNumber = objRecord.findSublistLineWithValue({
            sublistId: 'addressbook',
            fieldId: 'defaultbilling',
            value: true
        });
        objRecord.setSublistValue({
          sublistId: 'addressbook', 
          fieldId: 'addr1_initialvalue', 
          line: lineNumber, 
          value: 'NewValue' 
        });
        var recordId = objRecord.save();
b
e
I see my change here:
Copy code
"sublists": {
    "addressbook": {
      "line 3": {
        "addr1_initialvalue": "NewValue",
But not in NetSuite address tab
b
expect to learn how a subrecord isnt a sublist
👍 1
specifically from the link above, which isnt a short read
e
Ok, thanks. I will read it. Changing the sublist is probably not the correct way of doing this
Thanks for helping @battk 👍 I got it working 🙂
s
NFT smooths those differences over since different APIs for records/sublists/subrecords is annoying.
e
@stalbert What is NFT?
140 Views