Axapta V/s Me

Yet another blog for Dynamics 365 for Finance and Operations. This blog primarily targets the technical readers. I will be sharing my experience with Dynamics AX using code snippets, errors, and solutions, Tips, and tricks.

Join Two Tables at Run Time

How to join Two tables at RunTime, without using Datasource

static void QueryJoin2Tables(Args _agrs)
AxTestTable1 AxTestTable1;  // Table 1
AxTestTable2 AxTestTable2;  // another table which you want to join with table 1
Query q;
QueryBuildDataSource qbdAxTestTable1, qbdAxTestTable2;  // objects for both tables
QueryBuildRange qbr;
QueryRun qr;

        q = new Query(); //to make a new query

qbdAxTeatTable2 = q.addDataSource(tablenum(AxTestTable2)); // To Add table to query


         qbdAxTeatTable1 = qbdAxTestTable2.adddataSource(tablenum(AxTestTable));


    qr = new QueryRun(q); // to fetch records from query
AxTestTable1 = qr.get(tablenum(AxTestTable));


1 comment:


Note: Only a member of this blog may post a comment.