The Infolog

A blog of Dynamics AX development tips and tricks

Skip to: Content | Sidebar | Footer

Using a query with SysLookupMultiSelectCtrl

29 September, 2013 (01:21) | Dynamics AX | By: Howard Webb

If you wish to use the new SysLookupMultiSelectCtrl class there are a few construct methods out there that you can use. If you need to build one using a dynamic query object you can use this construct method, however the problem with this is that the lookup will contain all the fields in your table. To avoid this you need to remove the fields from the field list and then put in the fields you want:

 

public void dialogPostRun(DialogRunbase _dialog)

{

Query                   query = new Query();

QueryBuildDataSource    queryBuildDataSource = query.addDataSource(tablenum(AssetBook));

FormRun                 formRun;

;

 

super(_dialog);

 

formRun = _dialog.dialogForm().formRun();

queryBuildDataSource.addGroupByField(fieldnum(AssetBook, BookId));

queryBuildDataSource.fields().clearFieldList();

queryBuildDataSource.fields().addField(fieldNum(AssetBook, BookId));

 

fsCtrlMultiSelect1 = formRun.design().control(fbsCtrlMultiSelect1.id());

 

msCtrl1 = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlMultiSelect1, query);

}