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(); } |
Get Parent Position Worker Name from Current Worker Position | D365FO X++
Views (16)
In this blog, we explore how to fetch the Parent Position Worker from a Current Worker Position in D365FO.
The solution revolves around core HCM tables:
- HcmWorker,
- HcmPositionWorkerAssignment,
- HcmPosition,
- HcmPositionHierarchy.
Source Code:
This was originally posted here.

Like
Report
*This post is locked for comments