Get department name


How to get name of department(worker) using user id. tried using hcmworker.primarydepartmnetname() but it gives less userid department name.

What does that mean? May be explain with an example.

recId = HcmWorker::userId2Worker(curuserid());
use the above methods to retrieve the value for departments assigned to the user.

Thanks for ur reply. Example…taken Xyz as userid and want departnameof “xyz” userid but am able get name of department for xyz userid . tried ur code but not getting department name of userid.

Tried this code…while select OMOperatingUnit join HcmPositionDetail
where OMOperatingUnit.RecId == HcmPositionDetail.Department
join HcmPosition where HcmPositionDetail.Position == HcmPosition.RecId
join HcmPositionWorkerAssignment
where HcmPosition.RecId == HcmPositionWorkerAssignment.Position
join HcmWorker where HcmPositionWorkerAssignment.Worker == HcmWorker.RecId
join DirPerson where HcmWorker.Person == DirPerson.RecId
join DirPersonUser where DirPersonUser.PersonParty == DirPerson.RecId && DirPersonUser.User == userInfo.ID

\Data Dictionary\Tables\HcmWorker\Methods\getDepartments - It should be working.
Have you tried to debug and see why it is not working in your case?

Is the dept name available for the user???

If department is not assigned to user then the error may please check that.

how do check if department is assigned for particular user

Department will be assigned to the position, Human resources/Common/Organization/Positions/Positions
Also see,…/hh242239.aspx