Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get the department assigned for past workers only

(0) ShareShare
ReportReport
Posted on by 55

I have a requirement as the customer requested a report with all the workers (current & past ) on the system and there was a bunch of things else in it, my only problem is that the department is only retrived for the current workers the past workers doesn't retrieve their department name.

*This post is locked for comments

  • Verified answer
    Sukrut Parab Profile Picture
    Sukrut Parab 71,680 Moderator on at
    RE: Get the department assigned for past workers only

    If the report is needed for all workers then you have to change your query. Not sure why you are starting from userInfo table , unless requirement is different .  Start from hcmwoker table and  join it with HcmEmployment to get all the workers and use min date and max date when you query , You can further join dirPerson to get other info like name.   Once you know you are getting all the workers rest of the stuff you can easily get from other tables.

    Also take a note , HR tables are date effective , so write your queries using validTimeState() keyword. For more information yo can refer below link

    avantiico.com/.../

  • Omar Hesham Profile Picture
    Omar Hesham 55 on at
    RE: Get the department assigned for past workers only

    i created customized report  and this is the process report logic the problem here is that i get the department for the current workers only i want to get also for the past worker

    public void processReport()

    {

       RecId                        recid;

       UserInfo                     userinfo;

       DirPerson                    dirPerson;

       DirPersonUser                dirPersonUser;

       SysUserLog                   sysUserLog;

       HcmWorker                    hcmworker;

       HcmPositionWorkerAssignment  workerAssignment;

       HcmPosition                  hcmPosition;

       HcmPositionDetail            hcmPositionDetail;

       IsUserActiveContract        Contract;

       Contract =this.parmDataContract();

       ttsBegin;

            while select * from userinfo

                  outer join dirPersonUser

               where dirPersonUser.User == userinfo.id

                  outer join dirPerson

               where DirPersonUser.PersonParty == DirPerson.RecId

                  outer join hcmworker

               where HcmWorker.Person == DirPerson.RecId

                  outer join worker, position from workerAssignment

               where workerAssignment.Worker == hcmWorker.RecId

                  outer join recid from hcmPosition

               where hcmPosition.RecId == workerAssignment.Position

                  outer join hcmPositionDetail

               where HcmPositionDetail.Position == HcmPosition.RecId

            {

               TempTB.clear();

               TempTB.Name          =   DirPerson.Name;

               TempTB.IsEnabled     =   enum2str( userinfo.enable);

               TempTB.UserID        =   dirPersonUser.User;

               recId                =   HcmWorker::userId2Worker(TempTB.UserID);

               TempTB.Title         =   hcmworker.title();

               TempTB.UserID        =   userinfo.id;

                  select firstonly createdDateTime from sysUserLog order by createdDateTime desc where sysUserLog.UserId == TempTB.UserID;

                  TempTB.LastLogon     =   sysUserLog.createdDateTime;

                  TempTB.Department    =   HcmWorker::getDepartments(recId).Name;

               TempTB.insert();

            }

       ttsCommit;

     }

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,494 Super User 2025 Season 1 on at
    RE: Get the department assigned for past workers only

    Hi Omar,

    Did you use a standard report or do you have a custom one? When it is a custom report, check the coding and see if records are retrieved with a date in the past to get the correct position details for past workers.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,313 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans