Thursday, November 7, 2024

Adding multiple Query range in Dynamics 365 FO

Using OR:

QueryBuildRange qbr = SysQuery::findOrCreateRange(_qbds, fieldNum(HcmPerfJournal, Owner));

qbr.value(strFmt(‘(%1.%2 == %3) || (%1.%4 == %5)’,
_qbds.name(),
fieldStr(HcmPerfJournal, Owner), enum2int(HcmPerfManagerEmployee::Manager),
fieldStr(HcmPerfJournal, Share), enum2int(NoYes::Yes)));
qbr.status(RangeStatus::Hidden);

Using AND:

queryBuildRange = accessRightsListDataSource.addRange(fieldnum(DEL_AccessRightsList, RecId));
queryBuildRange.value(strfmt(‘((%1.%2==%3) && (%1.%4==%5))’,
accessRightsListDataSource.name(),
fieldstr(DEL_AccessRightsList, RecordType),
accessRecordType,
fieldstr(DEL_AccessRightsList, Id),
_securityKeyArray.value(i)));

Date Range:

queryBuildRange .value(SysQueryRangeUtil::dateRange(DateTimeUtil::date(DateTimeUtil::addDays(currentDateTime,relativeDaysFrom)), DateTimeUtil::date(DateTimeUtil::addDays(currentDateTime,relativeDaysTo)));

or

queryBuildRange.value(SysQuery::range(fromDate, toDate));