web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Current user position name in D365Fo

(0) ShareShare
ReportReport
Posted on by 1,215

Hi guys,

How to get Current user position name in x++.

Thanks

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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();

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    First you need to find the worker associated with current user:

    robscode.onl/.../

    Then the current position of the worker:

    dynamicsax4u.wordpress.com/.../

  • Verified answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    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.

  • Riyas ahamed F Profile Picture
    1,215 on at

    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 ?

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    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.

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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();

  • Riyas ahamed F Profile Picture
    1,215 on at

    Many thanks Sergei Minozhenko and Nikolaos Mäenpää.

  • Riyas ahamed F Profile Picture
    1,215 on at

    HcmPositionWorkerAssignment only description method.

  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    Hi Riyas,

    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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 291 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans