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

lookup querry to get workers under cuurnet user/manger

(0) ShareShare
ReportReport
Posted on by

hello evryone i'm new to D365 F&O and i have a task where i need to create a field in a dialog that shows the name of the workers under the current user 

So i have this line of code

 

HcmPositionWorkerAssignment::doesWorkerReportToManager(hcmWorker.recId,HcmWorker::find(HcmWorkerLookup::currentWorker()).recId,true);

that is supposed to return true if a worker is under the current user.

So My problem is i don't know how tu use it in a lookup querry

My dialog table name NouvelleMesuresDialogTmp and the field is Employee

any help would  be nice thank you 

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Wassim77,

    Can you elaborate on the functional requirement? Just mentioning that you have a dialog, does not tell what it is about. You also shared just a technical table name which is a customization. We can't guess what exactly you need to achieve. Can you clarify your requirement with a detailed description and/or a screenshot as illustration?

  • Community Member Profile Picture
    on at

    thank you André for your response i will try to clarify.

    i'm creating Disciplinary Mangement system under Employee Selfservice in order to do that a created a new form 

    in this form when clicking on the new button a dialog opens in this dialog the user needs enter some informations and some other informations are already initialized like the current user 

    i have a field where the user chose a worker from his team to apply the mesure on him 

    pastedimage1663629635201v1.jpeg_2D00_640x480.jpg_2D00_640x480.jpg

    So here i need to get the team circled in blue into my field cicled in black 

     Capturemydialog2.JPG

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi wassim77 ,

    You need to use 3 tables to get the workers who all are reporting to team leader.

    1. Get the position for the "Team Leader".

    2. Join HcmWorker - HcmPositionWorkerAssignment - HcmPosition - HcmPositionHierarchy with the relations.

    3. Add range to HcmPositionHierarchy table for field "ParentPosition" and the value should be the "Team leader" position.

    Thanks,

    Girish S.

  • Community Member Profile Picture
    on at

    Thank you for your response girishs

    I'm really new to d365 can you elaborate more

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi wassim,

    So lets go step by step, Try to get the "Team Leader"( from your screen shot it is "Julia funderbuek") position using select statement.

    After that you can build lookup query.

    Thanks,

    Girish S.

  • Community Member Profile Picture
    on at

    So this is my code

     

    Query query = new Query();
    
           QueryBuildDataSource queryBuildDataSource;
    
           QueryBuildRange queryBuildRange;
    
           SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmWorker), sender);
    
           sysTableLookup.addLookupField(fieldNum(HcmWorker,PersonnelNumber));
    
           sysTableLookup.addLookupMethod(tableMethodStr(HcmWorker,name),true);
    
           queryBuildDataSource = query.addDataSource(tableNum(HcmWorker));
    
           sysTableLookup.parmQuery(query);
    
           sysTableLookup.performFormLookup();

  • GirishS Profile Picture
    27,827 Moderator on at

    On the same lookup method get the team leader position using select statement.

    After that add the datasource with hcmworker table as mentioned in the previous posts.

    Add the range to parent position field. Query value you will get it from select statement .

    Thanks,

    Girish S.

  • Community Member Profile Picture
    on at

    can you perform the changes on te code please

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi wassim,

    Try it on your own, If you had any doubt means you can post here we will help you with suggestions.

    Please see the below link for getting the position assigned to the worker.

    https://dynamicsax4u.wordpress.com/2014/05/16/get-position-of-a-worker/

    Also for lookup with multiple table joins and ranges, please see below link.

    https://learn.microsoft.com/en-us/dynamicsax-2012/developer/how-to-add-a-lookup-form-to-a-control

    Thanks,

    Girish S.

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Wassim,

    Are you able to solve this?

    Thanks,

    Girish S.

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 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans