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)

Join multiple table in Query in X++

(0) ShareShare
ReportReport
Posted on by 385

Dear All

I have make make query using X++ join three table but desire result not showing 

Please help me and let me know is it ok ??

qbdsCustInvoiceJour = query3.addDataSource(tableNum(CustPackingSlipJour));
qbdsCustInvoiceJour.relations(true);
qbdsCustInvoiceJour.joinMode(JoinMode::InnerJoin);

qbdsCustTable=qbdsCustInvoiceJour.addDataSource(tableNum(CustTable));
qbdsCustTable.relations(true);
qbdsCustTable.joinMode(JoinMode::InnerJoin);

qbdsGatePassLine = qbdsCustInvoiceJour.addDataSource(tableNum(GatePassLine));
qbdsGatePassLine.relations(true);
qbdsGatePassLine.joinMode(JoinMode::NoExistsJoin);
qbdsGatePassLine.fields().addField(fieldNum(GatePassLine,InvoiceId));

qbdsCustInvoiceJour.fields().addField(fieldNum(CustPackingSlipJour,PackingSlipId));
qbdsCustInvoiceJour.fields().addField(fieldNum(CustPackingSlipJour,SalesId));
qbdsCustInvoiceJour.fields().addField(fieldNum(CustPackingSlipJour,InvoiceAccount));

qbdsCustTable.fields().addField(fieldNum(CustTable,AccountNum));
Customerqbr= qbdsCustTable.addRange(fieldNum(CustTable,CompanyChainId));
Customerqbr.value(queryValue(("GDN GP")));

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    Can you explain your problem, please? Fixing an unknown problem is quite difficult.

    I strongly recommend you look at the query you generated and compare it with what you intended. Call qbdsCustInvoiceJour.toString() to get the SQL-like query string. You'll probably need to add .fetchMode(QueryFetchMode::One2One) on the child data sources to see them there (or to restructure your query to use CustTable as the root datasource).

    By the way, make sure that your GatePassLine table has a corresponding relation.

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

    Also your query is wrong in a sense that you are doing addField calls, but AX automatically adds all fields for you. You only need to add specific fields, if you have cleared the field list beforehand.

    Also you should consider using SysQuery::findOrCreate* method as a good practice to avoid adding duplicate datasources, ranges, whatsoever in the future.

    Finally, check the generated query as Martin suggested in order to be sure the data you are expecting would show, like you are not missing records for the value you are trying to filter for, you are also in the correct legal entity (company), there are relations correctly defined between the tables, and finally exprimenting with the fetch mode.

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