how do you prevent a sublist from being overriden ...
# ask-stanley-ai
p
how do you prevent a sublist from being overriden from the api? we created an address and it overrode the address through the api
c
AI generated answer (using internal Slack threads):
To prevent a sublist from being overridden from the API, you need to ensure that you are correctly identifying and handling the sublist records. In the case of addresses in NetSuite, there are two different IDs: the internal ID and the address internal ID. These are not the same and can cause confusion if not handled correctly. When you are updating an existing address, you should use the
getSublistSubrecord
method to get the address sublist record. Here's an example:
Copy code
javascript
var customer = record.load({ type: record.Type.CUSTOMER, id: 19979 });
var addressSubRecord = customer.getSublistSubrecord({ sublistId: "addressbook", fieldId: "addressbookaddress", line: 0 });
This will return an address with an internal ID. If you want to get the address internal ID, you should use the
getSublistValue
method:
Copy code
javascript
var addressInternalId = customer.getSublistValue({ sublistId: "addressbook", fieldId: "id", line: 0 });
When you are updating the address, you should use the correct ID depending on your needs. If you are using the internal ID, you should use the
getSublistSubrecord
method. If you are using the address internal ID, you should use the
getSublistValue
method. Remember, when you are creating or updating addresses in a sublist, you should select the correct sublist. For example, if you are creating addresses for a contact, you should select the address book sublist from the contact, not the customer. ****** 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.818776369
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816179574
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811834037
Please provide your feedback on this answer.