Hi,
Today i got a scenario while working in payroll module, to get the terminated workers only using x++ query or adhoc query.
Below code helped me to achieve the requirement.
subQuery = new Query();
qbdsEmployment = subQuery.addDataSource(tableNum(HcmWorker));
qbdsEmployment.addSelectionField(fieldNum(HcmWorker, PersonnelNumber));
qbdsEmployment = qbdsEmployment.addDataSource(tableNum(HcmEmployment));
qbdsEmployment.joinMode(JoinMode::InnerJoin);
qbdsEmployment.relations(true);
qbdsEmployment.addLink(fieldNum(HcmEmployment,Worker),fieldNum(HcmWorker,RecId));
//workerRange = qbdsEmployment.addRange(fieldNum(HcmEmployment, Worker));
validFromRange = qbdsEmployment.addRange(fieldNum(HcmEmployment, ValidFrom));
validToRange = qbdsEmployment.addRange(fieldNum(HcmEmployment, ValidTo));
subQuery.validTimeStateDateTimeRange(DateTimeUtil::minValue(), DateTimeUtil::utcNow());
validFromRange.value(SysQuery::valueUnlimited());
validToRange.value(SysQueryRangeUtil::lessThanUtcNow());
qbdsEmployment.addSelectionField(fieldNum(HcmEmployment,Worker));
qbdsEmployment.addSelectionField(fieldNum(HcmEmployment,ValidFrom));
qbdsEmployment.addSelectionField(fieldNum(HcmEmployment,ValidTo));
No comments:
Post a Comment