Validation of the address has failed. Please verif...
# ask-stanley-ai
p
Validation of the address has failed. Please verify that the address is valid after you save the subsidiary record.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you're having trouble with address validation when saving a subsidiary record. This could be due to a number of reasons, but one common issue is that the address fields are not being correctly set or updated. If you're trying to update the address on a transaction, you should be aware that the
shippingaddress
subrecord on a transaction represents the custom address of that transaction. Changes to this address only affect that particular transaction. If you want to make changes to the address from the customer record, then you don't make the changes to the address of the transaction. Instead, you make it on the
addressbook
sublist of the customer. Each line of the
addressbook
sublist has an address subrecord, which is the subrecord you would need to modify. Here's a sample code snippet that shows how to load the address being used on the sale and edit that one:
Copy code
javascript
var customer = record.load({
  type: record.Type.CUSTOMER,
  id: context.newRecord.getValue({ fieldId: 'entity' }),
  isDynamic: true
})

customer.selectNewLine({
  sublistId: 'addressbook'
})

var addressSubrecord = customer.getCurrentSublistSubrecord({
  sublistId: 'addressbook',
  fieldId: 'addressbookaddress',
  line: 0
})

addressSubrecord.setValue({
  fieldId: 'city',
  value: capitalizeFirstLetter(lCity.toLowerCase())
})

addressSubrecord.setValue({
  fieldId: 'state',
  value: lState
})

addressSubrecord.setValue({
  fieldId: 'zip',
  value: lZip
})

customer.commitLine({
  sublistId: 'addressbook'
})
This code loads the customer record, selects a new line in the
addressbook
sublist, gets the current sublist subrecord, sets the values for the city, state, and zip fields, and then commits the line. ****** 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.837966442
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828130722
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816404641
Please provide your feedback on this answer.