AX 7. How to override form control methods using extensions.
In one of the previous posts we discussed how to override methods on form data source fields (AX 7. How to override form data source field methods without overlaying.). Today we will talk about form controls.
Let’s change a lookup, because it is a quite common customization.
/// Adds a lookup to the <c>CustAccount</c> control on <c>SalesTable</c> form.
AX 7. How to override form data source field methods without overlaying.
It is a common customization task to override standard form data source field methods like jumpRef(), modified() or validate().
User can add new control using form personalization and this control won’t support overridden logic. It could be critical if you are restricting field lookup values or adding validations.
One form could have several controls that refers to one data source field so you have to duplicate your code.
For example we want to add custom jumpRef() and validate() methods to itemId field on sales order form. To achieve this we have to either overlay it or use next approach.
First of all we will create class to handle method overrides.
Then we will create new event handler class and subscribe to OnInitialized event of SalesLine data source.
/// Provides the open main table functionality for an item.
/// Checks whether <c>ItemId</c> is valid.
//emulate super() call. Comment out to skip.
That’s all. Using this approach you can override any data source field method.