Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2023 Release Wave 1Check out the latest updates and new features of Dynamics 365 released from April 2023 through September 2023
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | All TechTalks
I've created a query with 2 tables, and joined them with the addlink method.
The parent table is the WMSOrderTrans, and the child is the InventTable, relation with ItemID.
I need the query to be ordered first by the IventTable.PrimaryVendorID and then with the WMSOrderTrans.ItemSortOrder and then WMSOrderTrans.ItemID.
My Code is something like:
queryWMSOrderTrans = new Query();qbds = queryWMSOrderTrans.addDataSource(tablenum(WMSOrderTrans));queryWMSOrderTrans.dataSourceTable(tablenum(WMSOrderTrans)).addDataSource(tablenum(InventTable));queryWMSOrderTrans.dataSourceTable(tablenum(InventTable)).joinMode(joinmode::InnerJoin); queryWMSOrderTrans.dataSourceTable(tablenum(InventTable)).addLink(fieldnum(WMSOrderTrans, ItemID),fieldnum(InventTable, ItemID));queryWMSOrderTrans.dataSourceTable(tablenum(InventTable)).addSortField(fieldNum(InventTable,PrimaryVendorID));
qbds = queryWMSOrderTrans.dataSourceTable(tablenum(WMSOrderTrans));
qbds.addSortField(fieldnum(WMSOrderTrans, ItemSortCode)); qbds.addSortField(fieldnum(WMSOrderTrans, ItemId));
Is there anyway I can give priority to the "addSortField(fieldNum(InventTable,PrimaryVendorID));"
Thanks.. Best Regards..
You can simply use InventTable as the first datasource and WMSOrderTrans as the linked one.
BTW you don't have to specify link and joinMode, qbds.relations(true) would do the same thing.
Both recommendations worked perfectly.
Hm, we have a similar issue. We are adding first salestable and then salesline to a query and then add the sort fields dynamically from a users list. If the user adds a field from the salesline to sort first it isn't working. In normal SQL the sort is applied after the join so it doesn't matter on which table the sortfield occurs, but in ax the sort field depends on a table?!?
I have a similar issue. I am adding some sort fields of parent datasource (WmsOrderTrans)and then in between comes one field of the child datatsource (InventDim) and after that again few sort fields of parent datasource. But the sorting on the child datasource field is not happening as expected.(I have used querybuilddatasource.addsortfield() methods)
Is there any way that I can place child datasource's sort field in between of the parent datasource field ?
My sorting requirement is in this way (Parent - P, Child -C)
P.field1, P.field2, P.field3,C.field1, P.field4, P.field5
As a workaround, you can create a view and sort the view.
Actually its a standard method I am trying to modify.The method already has sorting happening on parent table. I am trying to add child datasource sort field.
Just an update. If I use addOrderByField method instead of addSortField it worked.
Business Applications communities