AX / D365FO – GroupBy on Lookup problem

I have a custom lookup with a GroupBy inside Query statement

First time, when the is nothing choosen the group by works fine. If I choose something from list and again want to change it, now the group by is lost.

To solve the issue simply use sysTableLookup.parmUseLookupValue(false) like show in below code

        public void lookup()
            Query query = new Query();
            QueryBuildDataSource queryBuildDataSource;
            QueryBuildRange queryBuildRange;
            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(ots_GuidedSalesOrderEntryRules), this);
            sysTableLookup.addLookupField(fieldNum(ots_GuidedSalesOrderEntryRules, ToleranceType));
            queryBuildDataSource = query.addDataSource(tableNum(ots_GuidedSalesOrderEntryRules));

            QueryGroupByField queryGroupByField = queryBuildDataSource.addGroupByField(fieldNum(ots_GuidedSalesOrderEntryRules, ToleranceType));

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s