≡ Menu

Custom lookup in reference group Dynamics Ax 2012

Here is little tip regarding look up.
A few days ago, I have to take join with employee with my custom table. if you check that The primary key of HCMWORKER IS RecId.
So I have to create worker relation based on primary key i.e recid.\


But when I drop the foreign key on form Grid. It creates reference group. And surprising this create out of the box lookup with similar to same based on alternative key.

Now there is query appears that we have to filter it the workers of certain cariteria. for example you can certain designation or not terminate. now I face question how to add custom lookup in Reference group. Now there is no lookup function and same time if exists it will not work.
After searching I found referenceLookup method at data source field instead of grid text field. So Overwrite the method and similar code snippet creates the similar to out of the box lookup. You can extend it according to need.



public Common lookupReference(FormReferenceControl _formReferenceControl)

HcmWorker HcmWorker;
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;

SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(HcmWorker), _formReferenceControl, true);
sysTableLookup.addLookupField(fieldNum(HcmWorker, PersonnelNumber));
sysTableLookup.addLookupField(fieldNum(HcmWorker, Person));

queryBuildDataSource = query.addDataSource(tableNum(HcmWorker));

return sysTableLookup.performFormLookup();


Reference I used for this post, They help me during doing day to day task

{ 0 comments… add one }

Leave a Comment