Parag Chapre

How to get workers current position, department and manger in X++

How to get current user worker in X++
Spread the love

In Dynamics 365 F&O, we have HcmWorkerHelper class which gives much information about worker such as department, primary position, current legal entity and so on.

The code to get worker’s current position.

This gives current worker record.

HcmWorkerRecId   hcmWorkerRecId =  HcmWorker::userId2Worker(curUserId());
HcmPositionRecId hcmPositionRecId = HcmWorkerHelper::getPrimaryPosition(hcmWorkerRecId);

The code to get current worker manager.

HcmWorker currentWorker = HcmWorker::find(HcmWorkerLookup::currentWorker());
HcmWorker currentWorkerManager = HcmWorkerHelper::getManagerForWorker(currentWorker.RecId);

The code to get current worker department.

HcmWorker currentWorker = HcmWorker::find(HcmWorkerLookup::currentWorker());
OMOperatingUnit department = HcmWorkerHelper::getPrimaryDepartment(currentWorker.RecId);

The code to get current worker legal entity.

HcmWorker currentWorker = HcmWorker::find(HcmWorkerLookup::currentWorker());
CompanyInfo legalEntity = HcmWorkerHelper::getLegalEntity(currentWorker.RecId);
Leave a Reply

Your email address will not be published. Required fields are marked *