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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Sorting form with 2 data sources

(0) ShareShare
ReportReport
Posted on by 52

Hello,

I have been searching this question for days and i could not find any answer. My question is:
I have 2 data sources in my form. And i have a grid. This data sources are joined to each other with inner join. I have fields of both Data Source on my grid. Now i want to sort this grid with following order:

ds1.Name
ds1.Surname
ds2.ExamDate

The grid Data Souce is ds1.
How can i sort with this way?

Thanks a lot;

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    240,163 Most Valuable Professional on at

    Do you want to do it from GUI, or in code?

  • badiyev Profile Picture
    52 on at

    I want to do it with code, i mean, when the form loads.

    Thanks.

  • Mea_ Profile Picture
    60,286 on at

    Hi badiyev,

    Take a look at this community thread community.dynamics.com/.../127335

  • badiyev Profile Picture
    52 on at

    hello ievgen,

    Thanks  for your suggestion and reply, but unfortunately this is not what i am looking for.

  • Mea_ Profile Picture
    60,286 on at

    What are you looking for ?

  • badiyev Profile Picture
    52 on at

    The question is what i am looking for.

  • badiyev Profile Picture
    52 on at

    Martin, i am still facing with this problem, can you please suggest a solution?

    Best of Regards.

  • Martin Dráb Profile Picture
    240,163 Most Valuable Professional on at

    addSortField() does seem to be the answer. If you say it's not what you want, tell us why.

    Nobody replied because just saying "The question is what i am looking for" doesn't explain anything.

  • badiyev Profile Picture
    52 on at

    Martin,

    When i use addSortField(), it only sorts for the field i provided latest.

    For example: I use:

    On init() of first ds:

        this.queryBuildDataSource().sortClear();

       ds2_ds.query().dataSourceTable(tableNum(tb2)).addSortField(fieldNum(tb2, SomeDate));

       ds2_ds.query().dataSourceTable(tableNum(tb2)).addSortField(fieldNum(tb2, SomeFIeld));

       this.query().dataSourceTable(tableNum(tb1)).addSortField(fieldNum(tb1, RecId));

    Here, only sort one is by table 1.recid . I want it to be sorted, first by SomeDate, then by SomeField, then by recid.

    Best regards.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You could create a temporary table with an index that matches your field order, populate the records from the joined datasources, and use addSortIndex:

    msdn.microsoft.com/.../querybuilddatasource.addsortindex.aspx;MSPPError=-2147217396

    This is the only way probably that you could use to get it working.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans