Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to get Employee Name , Employee Department and Employee Company from D365 F&O DB

(0) ShareShare
ReportReport
Posted on by

Hello Experts ,  i have one requirement to set look up for employee so once employee name will be chose respected department and  company will come automatically. i was trying to figure out the relation between the table to get those details but couldn't find anything. please advise i am, using below quarries.  

Not Working :

SELECT A.PERSONNELNUMBER, E.NAME AS 'WORKER NAME', D.NAME AS 'DEPARTMENT'
FROM HCMWORKER A LEFT OUTER JOIN HCMPOSITIONWORKERASSIGNMENT B ON B.WORKER = A.RECID
LEFT OUTER JOIN HCMPOSITIONDETAIL C ON C.POSITION = B.POSITION
INNER JOIN DIRPARTYTABLE D ON C.DEPARTMENT = D.RECID
INNER JOIN DIRPARTYTABLE E ON A.PERSON = E.RECID

For getting employ name i am using this  and its working

select DP.NAME,* from HCMWORKER h, DIRPARTYTABLE DP where h.PERSON = DP.RECID 

Thank you 

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: How to get Employee Name , Employee Department and Employee Company from D365 F&O DB

    semihcelikol.com/.../

  • MohammadAB Profile Picture
    20 on at
    RE: How to get Employee Name , Employee Department and Employee Company from D365 F&O DB

    Hi Sachin,

    I am looking to create a similar report to get the department of the reportedbyperson. Did you manage to find the query?

    Kind Regards,

    MohammadA

  • Community Member Profile Picture
    on at
    RE: How to get Employee Name , Employee Department and Employee Company from D365 F&O DB

    Hello Guys, I can see in Human Resources > Employee while we are creating employee we have option to add company and department in employment > financial Dimension (TAB ). 

    Error95.PNG

    After investigating i found below table are responsible for this.

    • DimensionAttributeValueSet
    • DimensionAttributeValueSetItem
    • DimensionAttributeValue

    For Vendor table i wrote below query and it is giving me the department and company name.

    select dimensionAttributeValue.DISPLAYVALUE,* from HCMEMPLOYMENT  join dimensionAttributeValueSetItem on
    
     dimensionAttributeValueSetItem.DimensionAttributeValueSet = HCMEMPLOYMENT.DefaultDimension
    
     join dimensionAttributeValue on   dimensionAttributeValue.RecId = dimensionAttributeValueSetItem.DimensionAttributeValue
    

    But i am confused which table i should use for Employee department and company. I tried with HCM worker but it does not have DefaultDimension column also i tried with HCMEMPLOYMENT table but not getting correct result please advise.  

    So i will write a manual lookup to show only the department and company which is linked to this employee

  • Community Member Profile Picture
    on at
    RE: How to get Employee Name , Employee Department and Employee Company from D365 F&O DB

    Hello Blue, 

    Thank you so much for the response actually i am already able to pick current logged in user name and logged in date by using  initValue() method 

    public void initValue()
    { 
    super();
    this.ReportedDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
    this.ReportedByUser=HcmWorker::worker2Name(HcmWorker::userId2Worker(curUserId()));
    
    }

    Now i want respected department of that user and respected company should also picked automatically , once i  chose the ReportedByUser. Please find the screen shot below for more clarity. Same scenario  i want for assignee but assignee field i am getting value by using HcmWorkerRecId EDT in table field.

    Error94.PNG

  • Blue Wang Profile Picture
    on at
    RE: How to get Employee Name , Employee Department and Employee Company from D365 F&O DB

    Hi Sachin,

    Have you tried this?

    community.dynamics.com/.../current-user-and-its-employee-name

    HcmWorker::find(DirPersonuser::findUserWorkerReference(UserId)).name();
    HcmWorker::find(DirPersonuser::findUserWorkerReference(UserId)).primaryDepartmentName();

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,467 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans