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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Retrieve Hcm worker personnel number based on CurUserId()

(0) ShareShare
ReportReport
Posted on by 575

Hi Guys,

I want to retrieve the Worker personnel number from CurUserId . Can you please advice on this.

*This post is locked for comments

I have the same question (1)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    305,499 Super User 2026 Season 1 on at

    Hi Michael,

    You can get the record ID of the current worker with the command 'currentWorker()'. If you have a user ID, you can also use HcmWorker::userId2Worker() to get a record ID of the worker. Once you have the record ID, you can also retrieve the personnel number.

  • Verified answer
    Moeen Ahmed Sultan Profile Picture
    1,402 on at

    Create a job and paste the following recommended code:

    HcmWorker hcmWorker; 
    select * from hcmWorker 
    where hcmWorker.RecId == hcmWorker::userId2Worker(curUserId()); 
    info(strFmt("%1", hcmWorker.PersonnelNumber));

    OR use the following code for more clarity of the tables,

    DirPersonUser dirPersonUser; 
    DirPerson dirPerson; 
    HcmWorker hcmWorker; 
    select * from dirPersonUser 
    where dirPersonUser.User == curUserId(); 
    select * from dirPerson 
    where dirPerson.RecId == dirPersonUser.PersonParty; 
    select * from hcmWorker 
    where hcmWorker.Person == dirPerson.RecId; 
    info(strFmt("%1", hcmWorker.PersonnelNumber));

    Regards,
    Moeen Ahmed Sultan
  • e_zhu Profile Picture
    44 on at

    You can also use 

    HcmWorkerLookup::currentWorker()
    Cheers

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dekion Profile Picture

dekion 4

#2
Virginia99 Profile Picture

Virginia99 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans