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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Multiselect lookup distinct values- group by doesnt work

(0) ShareShare
ReportReport
Posted on by 8

Hi,

I have multiselect lookup control where I want to show distinct values since in the table that I am using as a query datasource I have multiple records with the same ID and I only want one to be shown.

I use 

qbds = query.addDataSource(tableNum(MyTable));
qbds.orderMode(OrderMode::GroupBy);
 qbds.addGroupByField(fieldnum(MyTable,Typeid));

But then when I want to get the container using 

container selectedRecords;
selectedRecords = msLookupCtrl.get();

I dont get anything in the container.

Note that when I dont use group by function, I get records in the container.

Any help? IS there some other way how I can select distinct? 

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,833 Moderator on at

    Hi techAx,

    Try to create a view and add the group by in the view itself.

    Use that view in the query.

    Thanks,

    Girish S.

  • techAx Profile Picture
    8 on at

    Hi Girish,

    Thank you for your answer.

    Instead of msLookupCtrl.get(); I tried msLookupCtrl.getSelectedFieldValues(); and it seems like it works, but if I have some more issues I will try your solution.

  • techAx Profile Picture
    8 on at

    P.S. Do you know how I can make multiselect lookup control to refresh everytime I change other field value? Example: I want my multiselect lookup to be filtered by company list that I select in my dialog. But it is only instantiated once and lookup doesnt hit next time when I change company list.

  • GirishS Profile Picture
    27,833 Moderator on at

    You need to use refreshQuery method.

    Refer to the below thread.

    community.dynamics.com/.../a-control-with-the-name-already-exists-on-the-form-when-i-build-lookup-with-syslookupmultiselectctrl

    Thanks,

    Girish S.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 576 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 366

#3
Adis Profile Picture

Adis 256 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans