Notifications
Announcements
No record found.
Hi guys,
How to get Current user position name in x++.
Thanks
Hi Riyas,You can try to fetch PositionId by primaryPositionId method on HcmWorker table and by position Id, you can fetch position name from the related table. User can be converted to a worker by build-in method HcmWorker::userId2Worker
HcmWorker::userId2Worker(curUserId()).primaryPositionId();
First you need to find the worker associated with current user:
robscode.onl/.../
Then the current position of the worker:
dynamicsax4u.wordpress.com/.../
Hi,
HcmWorker::findByPerson(DirPersonuser::find(currentUserId).PersonParty); will give you worker of current user. Join it with table HcmPositionWorkerAssignment to get the positions assigned to user.
Thanks for your replay Sergei Minozhenko,
in this format i can get only positionId but not getting name now i need it get in Report how to do ?
When you have an ID to some table, you can trust that almost in every case the table has a method which you can use to find the related record with the id.
For example HcmPosition has a method called findByPosition, which asks for Position Id.
Once you have the HcmPosition buffer fetched, you can use HcmPosition.title() method to get the name of the position.
Hi Riyas,
You can use method "description" on HcmPosition table and find record in HcmPosition by "findByPosition" method
HcmPosition::findByPosition(HcmWorker::userId2Worker(curUserId()).primaryPositionId()).description();
Many thanks Sergei Minozhenko and Nikolaos Mäenpää.
HcmPositionWorkerAssignment only description method.
One thing to remember, code shared by Sergei will give you a description for the only primary position. I don't know what is your requirement but if the person has more positions and you need details of all those positions then you have to use HcmPositionWorkerAssignment and HcmPosition to get the title as mentioned by Nikolaos.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 660 Most Valuable Professional
André Arnaud de Cal... 512 Super User 2025 Season 2
Sohaib Cheema 291 User Group Leader