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)

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
    237,976 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,284 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,284 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
    237,976 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

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