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 :
Microsoft Dynamics AX (Archived)

GroupBy on Lookup problem

(0) ShareShare
ReportReport
Posted on by

Hello,

I have problem with GroupBy query on Lookup. I have table TabA with price lists:

PriceListVersion | PriceSignCode | PriceSignDesc.

In table tabB I have column PriceListVersion, where a want check version of price list from popup. Each version should appear only once in the list.

I have code:

public void lookup(FormControl _formControl, str _filterStr)

{

    Query                   query = new Query();

    QueryBuildDataSource    queryBuildDataSource;

    SysTableLookup          sysTableLookup;

    ;

    sysTableLookup = SysTableLookup::newParameters(tableNum(TabA), _formControl);

    sysTableLookup.addLookupfield(fieldnum(TabA,PriceListVersion), true);

    queryBuildDataSource = query.addDataSource(tablenum(TabA));



    queryBuildDataSource.orderMode(orderMode::GroupBy);

    queryBuildDataSource.addGroupByField(fieldnum(TabA,PriceListVersion));



    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();

}

I check Query in Debbuger, in queryBuildDataSource we have:

 SELECT FIRSTFAST * FROM PriceSignListTable GROUP BY PriceSignListTable.PriceListVersion

But still there is no grouping on the form:

  4667.popup.PNG

What's the most interesting, sometimes it works properly, although I don’t change anything on popup or datasource.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hello Crispin,

    Thanks for your answers.

    I tried create an AOT query, effect is the same.

    I noticed that the popup works with an empty field:
    1460.popup.PNG
    Then in queryBuildDataSource we also have:

    SELECT FIRSTFAST * FROM PriceSignListTable GROUP BY PriceSignListTable.PriceListVersion

    If there is any value in the field, group by not working:
    1460.popup.PNG
    QueryBuildDataSource is still the same.

  • Community Member Profile Picture
    on at

    I'm afraid that sysTableLookup.addSelectionField(), does not work in AX 2009, i get error: class hasn't this method.

    It looks like it has been working since the AX 2012.

  • Suggested answer
    JII SAADUDDIN Profile Picture
    1,832 on at

    Hi Maces, try open AOT > Forms/Classes > find "tutorial_" you have existing lookup for samples standard in dynamics ax for beginners or starters in development

  • Community Member Profile Picture
    on at

    I tried use addSelectionField instead of addSelectionField, effect is still the same. I tried use they together, also without success.

    I was looking in these tutorials, i didn't find anythink like that (Lookup with groupBy).

  • Suggested answer
    xelifchemnitz Profile Picture
    5 on at

    For everyone also facing this problem:

    You have to use

    sysTableLookup.parmUseLookupValue(false);

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans