Description:-
Code:-
Note:-
In this article we will see how to remove previously added querybuildrange in query or else in datasource in ax 2012.
Code:-
void QueryRange(boolean _enabled) { QueryBuildDataSource qbds, qbds1, qbds2; QueryBuildRange qbr1, qbr2, qbr3; int i; ; qbds = journalTable_ds.query().dataSourceNo(1); // clear any previously added ds for (i = 1; i <= qbds.childDataSourceCount(); i++) { qbds2 = qbds.childDataSourceNo(i); qbds2.clearDynalinks(); qbds2.clearLinks(); qbds2.clearRanges(); qbds2.enabled(false); } // create the new ds if (_enabled) { qbds1 = qbds.addDataSource(tablenum(workflowWorkItemTable)); qbds1.enabled(_enabled); qbds1.relations(false); qbds1.joinMode(joinMode::ExistsJoin); qbds1.addLink(fieldNum(LedgerJournalTable, recId), fieldNum(workflowWorkItemTable, RefRecId), qbds.name ()); qbr1 = sysQuery::findOrCreateRange(qbds1,fieldnum(workflowWorkItemTable, userId), curuserid()); qbr2 = sysQuery::findOrCreateRange(qbds1, fieldnum(workflowWorkItemTable, status), enum2str(workflowWorkItemStatus::Pending)); qbr3 = sysQuery::findOrCreateRange(qbds1, fieldnum(workflowWorkItemTable, RefTableId), int2str(tablenum(LedgerJournalTable))); } }
Note:-
You can simply use clearRange()
instead of clearRanges(). If a class offers one useful operation, it's always
useful to check whether there isn't more useful stuff.
Another approach is to leave
the range in place and change its value to SysQuery::valueUnlimited().
Thanks for comments.....