I have a requirement to ensure validation of finanical dimension values for new Customers, Vendors, and Projects.
For Vendors (at least), I have customised DimensionDefaultingControllerBase.addEditControls to mark the mandatory dimensions with a red line.
if(formRun.name() == formStr(VendTable))&& dimAttr.BackingEntityType == tableNum(DimensionFinancialTag)&& dimAttr.Name == #IC3RD) { valueStringControl.mandatory(true); }
However, to handle the validation warnings on the form when attempting to save the record I'm using a post-event on the validateWrite() table method.
The Vendors form launches the Financial dimensions tab at the outset (before the record is created) so this is working fine with validateWrite().
However, for Customers and Projects, there are smaller forms that take basic details and save the record before launching CustTable and ProjTable forms. After this point I believe validateWrite() is not going be called.
I'm leaning towards using canClose() form events to force the user to select a value, but also would like the Edit button to activate the same logic when coming out of Edit mode (do I need to change CustTableInteraction class?).
Are there examples and/or recommendations in AX of both of these types of validation?