Get Parent Position Worker Name from Current Worker Position | D365FO X++
public Name getParentPositionWorkerName(HcmPositionRecId _positionRecId) HcmWorker hcmWorker; HcmPositionWorkerAssignment workerAssignment; HcmPositionHierarchy hcmPositionHierarchy; utcdatetime now = DateTimeUtil::getSystemDateTime();
// 1. Find the parent position in the hierarchy // 2. Join to the assignment table to find who sits in that parent position // 3. Join to the worker table to get the name select firstonly * from hcmWorker join workerAssignment where workerAssignment.Worker == hcmWorker.RecId && workerAssignment.ValidFrom <= now && workerAssignment.ValidTo >= now join hcmPositionHierarchy where hcmPositionHierarchy.ParentPosition == workerAssignment.Position && hcmPositionHierarchy.Position == _positionRecId && hcmPositionHierarchy.ValidFrom <= now && hcmPositionHierarchy.ValidTo >= now;
return hcmWorker.name(); } |
This was originally posted here.

Like
Report
*This post is locked for comments