'Can't force Customer Location's Override checkbox to check inside FieldUpdated handler of another field

For a new customer location initiated from the Customer Locations screen, after entering a new Location id, I'm trying to get the LocationCD's FieldUpdated event to empty out the new location's address default and check the Override checkbox. Setting the address fields to null works to empty them, but setting the OverrideAddress to true doesn't put a check in the checkbox.

Both controls have commit enabled on the screen itself. In a FieldUpdated event handler for OverrideAddress, it fires and I see the value change to true. In the LocationCD FieldUpdated handler, to set the value I use:

cache.SetValueExt<overrideAddress>(row, true);

Any ideas why it's not checking the box, or what could maybe be overriding or changing it back?

v21.208.0032



Solution 1:[1]

overrideAddress is a field in an address entry associated with the Location. The tricky thing about addresses is that the ERP has to keep the records past and present. So it can't just let you change the address that has been used in past Sales Orders. When you click the 'Override Address' checkbox in the UI, it creates a new address entry and adds it to the Location automatically so that you are essentially creating a new address. You should create a new Address with OverrideAddress = true and add it to the location during your event.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Patrick Chen