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

How to get user worker relation for past workers?

(2) ShareShare
ReportReport
Posted on by 102
Hi All,

I have written this piece of code to get user associated with worker.
Its working fine for active employees. For past worker the data not available in the dirperson table.
But in front end i can see the record with past worker associated with the user.

Please help me how to get user worker relation for past workers?
  DirPersonUser personUser  =   DirPersonUser::findParty(worker.Person); this.UserID               =   personUser.User;
Thanks in advance
  • Jahanvi Profile Picture
    on at
    How to get user worker relation for past workers?
    test
  • Verified answer
    PJ JohnPaul Profile Picture
    102 on at
    How to get user worker relation for past workers?
    Thank you so much Andre.
  • Verified answer
    André Arnaud de Calavon Profile Picture
    283,862 Test role Public on at
    How to get user worker relation for past workers?
    Hi JohnPaul,
     
    The table DirPersonUser is a table enabled for date effectiveness. In that case, by default, it will only select records currently active. If the record for the worker has an end date before the current date or a start date after the current date, it will not be selected. You can use an alternative way of finding the record, providing a range for effective records, e.g.
     
    DirPersonUser  dirPersonUser;
    utcDateTime    dateFrom;
    utcDateTime    dateTo = DateTimeUtil::utcNow(); 
     
    select firstonly validTimeState(dateFrom, dateTo) from dirPersonUser
        order by dirPersonUser.ValidTo desc
        where dirPersonUser.PersonParty == worker.Person;
    
    this.UserID = dirPersonUser.UserID;
     

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

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

#1
Jahanvi Profile Picture

Jahanvi 35

#2
PJ JohnPaul Profile Picture

PJ JohnPaul 5

#3
Anton Venter Profile Picture

Anton Venter 4 Moderator

Product updates

Dynamics 365 release plans