How can i update specific customer addresses witho...
# ask-stanley-ai
u
How can i update specific customer addresses without creating a new address?
c
AI generated answer (using internal Slack threads):
To update specific customer addresses without creating a new address, you can use SuiteScript 2.0. You can access the address sublist on the customer record and then get the sublist subrecord for the specific address you want to update. Here is a code snippet that demonstrates this:
Copy code
javascript
var customerRecord = record.load({
    type: record.Type.CUSTOMER,
    id: 'yourCustomerId'
});

var addressSubRec = customerRecord.getSublistSubrecord({
    sublistId: 'addressbook',
    fieldId: 'addressbookaddress',
    line: 0 // the line number of the address you want to update
});

// Now you can update the fields on the addressSubRec
addressSubRec.setValue({
    fieldId: 'addr1',
    value: 'New Address Line 1'
});

// Save the customer record
customerRecord.save();
This code loads the customer record, gets the address subrecord for the first address in the addressbook sublist (line 0), updates the 'addr1' field, and then saves the customer record. You can adjust the 'line' parameter to target different addresses in the addressbook sublist, and you can use the
setValue
method to update other fields on the address subrecord. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847317874
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844949782
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842659235
Please provide your feedback on this answer.