Here is the X++ code to find Worker Primary Position in given date time
public static HcmWorkerPrimaryPosition findByWorker(
HcmWorkerRecId _worker,
utcdatetime _validFrom = DateTimeUtil::utcNow(),
utcdatetime _validTo = _validFrom,
boolean _forUpdate = false,
ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
HcmWorkerPrimaryPosition hcmWorkerPrimaryPosition;
hcmWorkerPrimaryPosition.selectForUpdate(_forUpdate );
if (_forUpdate && _concurrencyModel != ConcurrencyModel::Auto)
{
hcmWorkerPrimaryPosition.concurrencyModel(_concurrencyModel);
}
if (_worker)
{
if (prmisdefault(_validFrom) && prmisdefault(_validTo))
{
select firstonly hcmWorkerPrimaryPosition
where hcmWorkerPrimaryPosition.Worker == _worker;
}
else if (_validFrom == _validTo)
{
select firstonly ValidTimeState(_validFrom) hcmWorkerPrimaryPosition
where hcmWorkerPrimaryPosition.Worker == _worker;
}
else
{
select ValidTimeState(_validFrom, _validTo) hcmWorkerPrimaryPosition
where hcmWorkerPrimaryPosition.Worker == _worker;
}
}
return hcmWorkerPrimaryPosition;
}
No comments:
Post a Comment