web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Multi Select Lookup - Group By (Selection is not displayed)

(0) ShareShare
ReportReport
Posted on by 5

Hello everyone,

i am trying to use a Multi Select Lookup for an SSRS report in combination with a temp table.

Therefore I use the "SysLookupMultiSelectCtrl" control, in which I insert the created data using a QueryRun. 

I do have the problem, that the Temp Table contains identical values. Therefore i have to "group by" the query.

The control works correctly as long as I don't use a Group By in the query.

2313.pastedimage1593764281386v1.png

Using the "group by" -> the values are not stored anymore in the control.

So after the selection the field stays blank:

0842.pastedimage1593764456882v2.png

My Query:

1200.pastedimage1593764509399v3.png

My Lookup code in the UI Builder:

private void lookupWEWLocationGroup()
    {
        QueryRun                queryRun;
       
        int         mutiSelectTableNum = tablenum(LoadedShelfLocationWMSLocationTmp_WEW);
        container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup))];
        
        queryRun = new QueryRun(queryStr(LoadedShelfLocationWMSLocationTmp_WEW));
        queryRun.setCursor(tmpWMSLocation);

        SysLookupMultiSelectCtrl::constructWithQueryRun(this.dialog().dialogForm().formRun(), dfWEWLocationGroup.control(), queryRun, false, selectedFields);
        
    }

I also tried to create the query in x , but there is the same problem. As soon as I use the "addGroupByField", the control doesn't store the values anymore.

My temporary table is of type "InMemory".

I found a simular post where someone asked a question (using a single lookup), but this solution doesn't work using the SysLookupMultiSelectCtrl.

https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/274768/groupby-on-lookup-problem

Anyone have any idea how to solve this problem?

Thanks in advance.

Best regards,

Dominik

I have the same question (0)
  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi Dominik,

    What AX version do you operate?

    Best regards,

    Ludwig

  • Dominik Starlinger Profile Picture
    5 on at

    Hi Ludwig,

    we are using D365 for Finance and Operations - PU35.

    Best regards,

    Dominik

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    ok. Moved that one to the d365 forum

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    If you cannot make it work this way, why not to group values in the temporary table when you insert them there?

    Otherwise, you need to share more details and show how you group the query.

  • Dominik Starlinger Profile Picture
    5 on at

    I have two multi select lookups, where the second one depends on the result of the first one.

    But I did not put the "range code" in my first post, because I got an explicit Problem using the "group by". 

    I try to give you some additional information:

    1. My report needs two multi select lookups where the second one depends on the first one.

    2. The second lookup get his data from an temporary table (In Memory).

     

    My UI Builder class looks like this:

    class LoadedShelfLocationUIBuilder_WEW extends SrsReportDataContractUIBuilder
    {
        private DialogField dfInventLocationId;
        private DialogField dfWEWLocationGroup;
        LoadedShelfLocationWMSLocationTmp_WEW tmpWMSLocation;
        
        LoadedShelfLocationContract_WEW contract;
    
        public void postBuild()
        {
            super();
    
            contract = this.dataContractObject();
    
            tmpWMSLocation.initTable();
    
            // binding dialogs with contract fields
            dfInventLocationId = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(LoadedShelfLocationContract_WEW, parmInventLocationId));
            dfWEWLocationGroup = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(LoadedShelfLocationContract_WEW, parmWEWLocationGroup));
    
        }
    
        public void postRun()
        {
            
            //this.lookupWEWLocationGroupCtrl();
    
            dfInventLocationId.registerOverrideMethod(methodStr(FormStringControl, lookup),
                methodStr(LoadedShelfLocationUIBuilder_WEW, lookupInventLocationId),
                this);
    
            dfWEWLocationGroup.registerOverrideMethod(methodStr(FormStringControl, lookup),
                methodStr(LoadedShelfLocationUIBuilder_WEW, lookupWEWLocationGroup),
                this);
    
            if (dfWEWLocationGroup)
            {
                dfWEWLocationGroup.lookupButton(2);
            }
    
            if (dfInventLocationId)
            {
                dfInventLocationId.lookupButton(2);
            }
    
        }
    
        private void lookupInventLocationId(FormStringControl _control)
        {
            Query                   query = new Query();
            QueryBuildDataSource    qbd;
    
            int         mutiSelectTableNum = tablenum(WMSLocation);
            container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(WMSLocation, InventLocationId))];
            
            qbd = query.addDataSource(tableNum(WMSLocation));
            qbd.addRange(fieldNum(WMSLocation, WEWLocationGroup)).value(SysQuery::valueNotEmptyString());
    
            qbd.addGroupByAndSelectionField(fieldNum(WMSLocation, InventLocationId));
            qbd.fields().dynamic(NoYes::No);
            qbd.fields().clearFieldList();
            qbd.fields().addField(fieldNum(WMSLocation, InventLocationId));
    
            SysLookupMultiSelectGrid::lookup(query, _control, _control, _control, selectedFields);
    
        }
    
        private void lookupWEWLocationGroup(FormStringControl _control)
        {
            Query                   query = new Query();
            QueryBuildDataSource    qbd;
            QueryRun                queryRun;
        
            int         mutiSelectTableNum = tablenum(LoadedShelfLocationWMSLocationTmp_WEW);
            container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup))];
    
            qbd = query.addDataSource(tableNum(LoadedShelfLocationWMSLocationTmp_WEW));
            qbd.addGroupByAndSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
            qbd.fields().dynamic(NoYes::No);
            qbd.fields().clearFieldList();
            qbd.fields().addField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
            
            //qbd.addRange(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, inventLocationId)).value(dfInventLocationId.value());
    
            SysLookupMultiSelectGrid::lookup(query, _control, _control, _control, selectedFields);
        }
    
        private void lookupWEWLocationGroupCtrl()
        {
            Query                   query = new Query();
            QueryBuildDataSource    qbd;
            QueryRun                queryRun;
           
            int         mutiSelectTableNum = tablenum(LoadedShelfLocationWMSLocationTmp_WEW);
            container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup))];
    
            //qbd = query.addDataSource(tableNum(LoadedShelfLocationWMSLocationTmp_WEW));
            //qbd.addGroupByAndSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
            //qbd.fields().dynamic(NoYes::No);
            //qbd.fields().clearFieldList();
            //qbd.fields().addField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
            
            //qbd.addRange(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, inventLocationId)).value(dfInventLocationId.value());        
    
            queryRun = new QueryRun(queryStr(LoadedShelfLocationWMSLocationTmp_WEW));
            queryRun.setCursor(tmpWMSLocation);
    
            SysLookupMultiSelectCtrl::constructWithQueryRun(this.dialog().dialogForm().formRun(), dfWEWLocationGroup.control(), queryRun, false, selectedFields);
    
    
        }
    
    }

    In the "tmpWMSLocation.initTable()" i create the data of the temp table.

    I tried different approaches using "SysLookupMultiSelectCtrl" and "SysLookupMultiSelectGrid".

    Both of them cause different Problems:

    The "SysLookupMultiSelectGrid" doesn't show any data at all (see "lookupWEWLocationGroup(FormStringControl _control)"):

    pastedimage1594020065709v1.png

    and the "SysLookupMultiSelectCtrl" got the "group by" Problem (see "lookupWEWLocationGroupCtrl()").

    As soon as I but the group by in the query, the selected values are not shown anymore in the control. The same problem occurs, when I am trying to write the query by code and change 

    addSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup)); to -> addGroupByAndSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));

    I am also still missing an "registerOverrideMethod" for "SysLookupMultiSelectCtrl", but there is the Problem, that the "SysLookupMultiSelectCtrl"-Class is also overriding the lookup method. 

    fsCtrlNames.registerOverrideMethod('lookup', 'ctrlNames_lookup', this); 

    So i am not even sure if it is possible?

    Maybe using the "SysLookupMultiSelectGrid" is the easier way to solve my problem, but i was not able to get it run.

    If you need more information, let me know.

    Thank you in advance. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans