22 Mar 2013

Different ways to create lookup

What is lookup

Lookup is a term that is used in ax for showing records from other tables as a drop downs. Not all drop downs are look ups. Base eums are also shown as drop down.

There are three methods of making a lookup

By overriding lookup method at the control level.

Please check the code of it in the xpo that I have attached with this post. Check the code in the following path
\Forms\TestLookupForm\Designs\Design\StringEdit:LookupTable2_Test\Methods\lookup

For showing the lookup customize Form check the following example in the xpo
\Forms\TestMainForm\Designs\Design\StringEdit:LookupFormCallingExample\Methods\lookup

This method has several advantages and certain limitations

a. You can define sort order
b. You can define order of the columns
c. You can define the query for the lookup which means you can filter more efficiently

Disadvantage

You need to override this method on every Form. So if you need the same functionality on all the places accessing the fields on the Form, you will have to explicitly over ride this method
There is also a change in the method signature in the Ax 5 and Ax6. In Ax6 lookups method doesn’t take any parameter.

Make relationship on the EDT.

Something like as below, This method is not supported on new Edts in Ax 2012. In this method, you just need to drag the field on the Form that has extended data type with relation, for instance ProjId, and the control will show the fields in the lookup that are in the Projtable –> auto lookup field group.

Ax 5 way



Ax 6 new EDTs



For the customized lookup Form, you can make a separate Form(I will compile a separate post for it) and define the menu item name of it in the Edt properties. For instance check the following snap shot of ProjId.



You can find the example of it in the following link
\Forms\TestMainForm\Designs\Design\StringEdit:LookupTable2_ProjIdAll

Lookup using a reference control

Ax 6 has introduced a new control for RecId fields. This change is due to lack of support for normal, field fixed and related field fixed relationship. Now Ax6 is more supporting traditional primary and foreign key relationships among tables.



You just need to set following two options

No comments:

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...