addSortField on multiple tables

Latest Axapta / Dynamics AX FAQ Pages

Get our Free Newletter

Don't you have the time to be online here at DUG every day? So how do you follow what is going on in the Dynamics industry and community?
If you subscribe to the DUG Newsletter then you can relax! We will make sure that you don't miss the big news!

Check out our
Newsletter Subscription Center
page a complete list of our different newsletters.

This post has 1 Reply | 1 Follower

1 Posts
11 Points
Joined: 2009-3-19
Last Online:
2009-3-24 17:03
Location: Italu
Andrea Posted: 2009-3-19 14:54 | Locked

Hi all,
I have a query with 2 DataSources (InventSum & InventDim).
I would to add a third DataSource (InventBatch, joined to InventDim) and I
would to order the resulting recordset by a field in the InventBatch table
I tried adding this code to the original query (querySum):
                    qbD = querySum.dataSourceTable(tablenum(InventDim));
                    qbd3 = qbD.addDataSource(tablenum(InventBatch));
                    qbd3.addlink(fieldnum(InventDim, inventBatchId),
fieldnum(InventBatch, inventBatchId));
                    qbd3.addSortField(fieldnum(InventBatch, expdate));

But it didn't work because the original query is already ordered by the
field InventBatchId (from the InventDim table), so my result is ordered first
by InventBatchId and then by expDate.
How can I "change" this order, sorting by expDate and then by InventBatchId?
Is it possibile to edit the sorting order or do the sorting fields of the
main table always take priority on the child table sorting fields?
And in this case is there a solution?

Thanks in advance for your help. Kind regards.


2,160 Posts
47,322 Points
Joined: 2003-1-21
Last Online:
2015-6-8 18:26
Location: Herts, England
Harish Mohanbabu replied on 2009-3-24 12:37 | Locked

Hi Andrea,

Try calling two properties - clearSortIndex() and sortClear().   And then try setting up sort field.

Hope this helps,

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

Page 1 of 1 (2 items) | Get this RSS feed | Bookmark and Share