Skip to main content

Notifications

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? 

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Multiselect lookup distinct values- group by doesnt work

    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.

  • techAx Profile Picture
    techAx 8 on at
    RE: Multiselect lookup distinct values- group by doesnt work

    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.

  • techAx Profile Picture
    techAx 8 on at
    RE: Multiselect lookup distinct values- group by doesnt work

    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.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Multiselect lookup distinct values- group by doesnt work

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,031 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,868 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans