blog for Dynamics Axapta

Posts tagged ‘Ax2012 Query Range’

Add Query Range for Same Table with Different DataSources

Hi Friends,

Here I have posted the code(not entire job/program) for adding multiple ranges/relations with the same table using Query object

Code Starts Here:

QueryRun qr;

//1st DataSource

QueryBuildDataSource qbdTableSourcefromQuery; // get query from the AOT Query which used by System in SysQuery()
QueryBuildDataSource qbdTableSourcefromCode; // newly added Query for Account Number Range

qr = new QueryRun(“your Query”);

qbdCustTableSourcefromQuery = SysQuery::findOrCreateDataSource(qr.query(), tableNum(TableName1));

SysQuery::findOrCreateRange(qbdCustTableSourcefromQuery, fieldNum(TableName1, FieldName)).value(“QueryValue”);

//2nd DataSource

qbdCustTableSourcefromCode = qbdCustTableSourcefromQuery.addDataSource(tableNum(TableName1), “TableNameNew”);
qbdCustTableSourcefromCode.relations(true);
qbdCustTableSourcefromCode.joinMode(JoinMode::ExistsJoin);
qbdCustTableSourcefromCode.addRange(fieldNum(TableName1, FieldName)).value(queryValue(“QueryValue”));

 

// Vasanth Arivali

Advertisements