How to define a custom lookup form for an extended datatype

 
Good morning, continuing on the topic of various custom lookup how-tos,
 
Normally, the relation specified on an extended datatype defines its lookup method, however, it is possible to override that with a custom lookup to use automatically everywhere that datatype is used. This way, you don’t need to override lookup methods on every individual forms.
 
Create a new Form, called SalesIdLookup maybe. On the SalesId datatype, for property ‘FormHelp’ pick your newly created lookup form. To be simple, your lookup form should be a standard one grid, non-resizable form.
In code, specify the lookup control in the init() of your form (right after super()):
element.selectMode(SalesTable_SalesId); //For example, this refers to the column of your lookup that users should click on.
 
On your lookup form’s design, specify the following properties:
[WindowType = Popup],
[Frame = Border],
[HideIfEmpty = No]
 
Et voila, everywhere the SalesId datatype will be used, your lookup form will be automatically invoked.
This entry was posted in Dynamics Ax 4.0x. Bookmark the permalink.