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

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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: