
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?
*This post is locked for comments
I have the same question (0)Hi _MGP,
I think it's not a good idea trying to validate already created record. User should be able to close customer record without any changes because he could open it accidentally and simple does not know right values for financial dimensions. However, in case of any changes validateWrite would be triggered. But again user should be able to close a form without saving changes by pressing "Esc".
As a solution, you can modify that "small" form to add financial dimension there with all required validation, so user won't be able to create new customer without entering them. You can find various blogs in the web explaining how to do this, for example, community.dynamics.com/.../how-add-financial-dimension-on-forms-inside-ax2012