I have an integration that is writing sales order ...
# suitescript
p
I have an integration that is writing sales order addresses with the full state name. I have created a UE script and I'm fixing the state values to be the two digit abbreviation. This is working but the addrtext is not updating with the change so you still see the full state name. Is there a way to cause that addrtext to be regenerated after my state edit? I tried setting it to '' My code:
Copy code
let shipToAddress = rec.getSubrecord({
                    fieldId: 'shippingaddress'
                });

if (shipToAddress) {
                    const shippingState = shipToAddress.getValue({ fieldId: 'state' });
                    log.debug('shippingState', shippingState);

                    // Validate and update shipping state
                    const newShippingState = updateState(shippingState);
                    if (newShippingState !== shippingState) {
                        shipToAddress.setValue({ fieldId: 'addrtext', value: '' });
                        shipToAddress.setValue({ fieldId: 'override', value: false });
                        shipToAddress.setValue({ fieldId: 'state', value: newShippingState });
                        log.debug('shippingAddress edited', shipToAddress);
                        log.debug('Billing Address Updated', `Updated Billing State from ${shippingState} to ${newShippingState}`);
                    } else {
                        log.debug('No update made for shipping state: not custom or no change');
                    }
                }
f
I think fix at the integration layer. Cheaper there.
p
That was my first choice but there are some edge cases that the integration layer can't handle and is breaking requiring user interaction. Making the adjust here seemed like it was going to be easy, which it was except for netsuite not updating the displayed address.
f
Belt + Suspenders. Do it in both places.