Mike Robbins
12/20/2023, 2:18 PMaddress2 field. So when this script attempts to update the address, we'll now have the city in both address2 and city.
If I load a sales order, open the subrecord and set city to null, the city field is emptied as expected. If I try setting all of the address fields and set city to null, the city field is still populated.
This code takes an object with properties that match the address subrecord. I've tried changing the order so that country and zip are populated first, I've tried loading the record in standard and dynamic mode. Any thoughts as to how I can set all address fields but have the city field remain empty?
const addressFieldIds = ['country', 'zip', 'addressee', 'attention', 'addr1', 'addr2', 'city', 'state', 'phone'];
const addressRecord = transaction.getSubrecord({ fieldId: subRecordFieldId });
addressFieldIds.forEach(function(fieldId) {
let value = fieldId === 'country'
? getISOCountryCode(address[fieldId]) // Convert "United States" to "US"
: address[fieldId];
addressRecord.setValue({ fieldId, value: value || null, });
});alien4u
12/20/2023, 2:24 PMAnthony OConnor
12/20/2023, 2:27 PMaddress2 rather than city
can you not just test if address2 === city
addresss2 = null?Mike Robbins
12/20/2023, 2:48 PMaddress2 isn't valid is most cases. It might contain 'Suite123' which is a perfectly valid value. The goal is to make the custom address match the original address (before changing the customer) exactly.Anthony OConnor
12/20/2023, 3:52 PMMike Robbins
12/20/2023, 3:54 PM