Monday, March 21, 2022

Worker position in D365 FO

 display str workerPositionId()

    {

        HcmPositionDetail               hcmPositionDetail;

        HcmPosition                     hcmPosition;

        HcmPositionWorkerAssignment     workerAssignment;

        HcmWorker                       hcmWorker;

        HcmJob                          hcmJob;


        select hcmPositionDetail

            join  hcmPosition

                where hcmPositionDetail.Position == hcmPosition.RecId

            join  workerAssignment

                where hcmPosition.RecId == workerAssignment.Position

            join  hcmWorker

                where hcmWorker.RecId == workerAssignment.Worker

                &&    hcmWorker.RecId == this.Worker;

        select * from hcmjob

            where hcmjob.RecId==hcmPositionDetail.Job;

        return hcmjob.JobId;

    }