POST, PUT, or PATCH when adding an address to a su...
# ask-stanley-ai
j
POST, PUT, or PATCH when adding an address to a subcustomer that has no address?
c
AI generated answer (using internal Slack threads):
When adding an address to a subcustomer that has no address, you would typically use a POST method if you are creating a new record. However, in the context of NetSuite, you would use the SuiteScript API to add an address to a subcustomer. Here is a sample code snippet based on the conversations:
Copy code
javascript
var customerRec = record.load({
    type: record.Type.CUSTOMER,
    id: 'yourCustomerId'
});

var myaddressSubrecord = customerRec.getCurrentSublistSubrecord({
    sublistId : "addressbook",
    fieldId : "addressbookaddress"
});

// Set the address fields
myaddressSubrecord.setValue({
    fieldId: 'addr1',
    value: '123 Main St'
});
myaddressSubrecord.setValue({
    fieldId: 'city',
    value: 'Anytown'
});
myaddressSubrecord.setValue({
    fieldId: 'state',
    value: 'CA'
});
myaddressSubrecord.setValue({
    fieldId: 'zip',
    value: '98765'
});

// Commit the changes
customerRec.commitLine({
    sublistId: 'addressbook'
});

// Save the record
var customerId = customerRec.save();
****** 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.837620676
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835589
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834858418
Please provide your feedback on this answer.
Thank you for your feedback