Today we see how to send range value for dynamic query in D365FO using X++.
As per requirements we need to send different ranges. Mostly all ranges are covered below.
Query query = new Query(); QueryBuildRange qbr; qbr = query.addDataSource(tableNum(CustTable)).addRange(fieldNum(CustTable, CustGroup)); qbr.status(RangeStatus::Locked); // To lock qbr.value('Value');//If record not found It will filter remaing records. qbr.value('4000..4050');//between operator qbr.value(queryValue('Value'));//Search with only sending value. qbr.value(SysQuery::value('Value'));//Search with only sending value. //like operator qbr.value(SysQuery::valueLike('Value')); //Filter without the sending value qbr.value(SysQuery::valueNot('Value')); //Retrive all records qbr.value(SysQuery::valueUnlimited()); //Retrive Null records qbr.value(SysQuery::valueEmptyString()); //Retrive Not Null records qbr.value(SysQuery::valueNotEmptyString()); //To give range qbr.value(SysQuery::range(fromDate, toDate)); //To find total number of records available in the resulting query info(strFmt('%1',SysQuery::countTotal(queryRun))); //find total number of Datasource available in the resulting query info(strFmt('%1',SysQuery::countLoops(queryRun)));
Multiple Ranges:
QueryBuildDataSource ledgerJournalTrans_DS = _contract.getQuery().dataSourceTable(tableNum(LedgerJournalTrans)); QueryBuildRange qbr = SysQuery::findOrCreateRange(ledgerJournalTrans_DS, fieldNum(LedgerJournalTrans, DataAreaId)); qbr.value(strFmt("(%1.%2 == %3) || (%1.%4 == %3)", ledgerJournalTrans_DS.name(), fieldStr(LedgerJournalTrans, AccountType), enum2int(LedgerJournalACType::Bank), fieldStr(LedgerJournalTrans, OffsetAccountType))); qbr.status(RangeStatus::Hidden); queryRun = new queryRun(_contract.getQuery());
Keep Daxing!!
No comments:
Post a Comment