Thursday, March 25, 2021

X++ Query with multiple Data Source and Ranges

Check Code,

Query X++ code in d365 f and O,

Query                   query               = new Query(); 

QueryBuildDataSource    qbds;    

QueryRun                queryRun; 

qbds = query.addDataSource(tableNum(Table1));

qbds.addRange(fieldNum(Table1, Field)).value(queryValue(Any Type));

qbds = qbds.addDataSource(tableNum(Table2));

qbds.relations(false);

qbds.addlink(fieldNum(Table1, Field), fieldNum(Table2, Field));

qbds.addRange(fieldNum(Table2, Field)).value(queryValue(SysQuery::range(Any Type)));

qbds = qbds.addDataSource(tableNum(Table 3));

qbds.relations(false);

qbds.addlink(fieldNum(Table1, Field), fieldNum(Table3, Field));

qbds.addRange(fieldNum(Table 3,  Field)).value(queryValue(Any Type));

queryRun = new QueryRun(query);

while(queryRun.next())

{

table name = queryRun.get(tablenum(Table));

}

For Date Range,

qbds.addRange(fieldNum(table, ValidFrom)).value(queryRange(rangeStart, rangeEnd));

No comments:

Workflow Approver Name For PurchRequsition Order

 For First Approver, this.workflowApprover(purchReqTable.RecId);     public void workflowApprover (RecId _recId)  // Requsation Table RecId ...