Category Archives: Multiselection lookup

How to select multiple records from lookup-Part-1(SysLookupMultiSelectCtrl)

Today i would share how to create a lookup to select multiple items in Dynamics AX 2012 forms.

In normal lookup methods we can only select one item at a time but in AX 2012 has introduced new class SysLookupMultiSelectCtrl to achieve the same without any hassle.

There are multiple ways to achieve the same but today i will demonstrate how can we have a site lookup with provision to select more then one item selection on parameter form in dynamics ax.

Multiselect lookup.png


  1. Create a Query named InventSiteQR that will contains data source e. InventSiteas shown in the below figure.

QueryMultiple lookup.PNG

2.Create the control on the form, set the auto declaration property to yes

Multiselect lookup

3.Declare instance of class SysLookupMultiSelectCtrl In the Class Declaration of the form:

public final class FormRun extends ObjectRun
 SysLookupMultiSelectCtrl msCtrlSite;


4.Write below code in the Init method of the form:

public void init()
 msCtrlSite = SysLookupMultiSelectCtrl::construct(element, SplitCostingProd, 
querystr(InventSiteQR),false, [tableNum(InventSite), fieldNum(InventSite, SiteId)]);

5.Add new field container type on parameter table named InventSiteCon

6.Write below code on the active method of form parameter table data source to update the control on load of the form:

public int active()

7.Write below code on the modified method of form control to get the selected record values from lookup and update those values to parameter Table:

public boolean modified()
 boolean ret;
 container conSite;
 RefRecId recid;
 int i;
 InventSite inventSite;
 container roleIds, roleNames;

 ret = super();
 conSite = msCtrlSite.get();
 for(i = 1;i<=conLen(conSite);i ++)
 recid = conPeek(conSite,i);
 select firstOnly inventSite where inventSite.RecId == recid;
 roleIds += inventSite.RecId;
 roleNames += inventSite.SiteId;
 ProdParameters.InventSiteCon = [roleIds,roleNames];
 return ret;


Thats it. Happy Daxing 🙂


Tags: , , , , , ,