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

Notifications

Announcements

Community site session details

Community site session details

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

How to get Employee name in my field by selecting lookup with employee Name and employee Id

(0) ShareShare
ReportReport
Posted on by 170

Hi there,

I have a requirement

I need to get employee name in my field and that field has lookup with employee name and employee id, when i select a record from that lookup then employee name has to sit in my field as value.

I have written this code and i'm getting lookup with employee id and employee name but while selecting employee id is getting in my field as value but i want employee name

My field Validation -User input - Use Drop Down from Employee Master showing Emp. Number and Name and select employee name

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmWorker), sender);


Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource qbdsJoin,qbdsJoin1;


qbds= query.addDataSource( tableNum(HcmWorker));

qbdsJoin= qbds.addDataSource( tableNum(DirPerson));
qbdsJoin.relations( true);


sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield( fieldNum(HcmWorker,PersonnelNumber ),true);
sysTableLookup.addLookupMethod(tableMethodStr(HcmWorker,Name));
sysTableLookup.performFormLookup();

Thank you.

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ax Trainee,

    What version are you using - AX 2012 or D365 F&O?

    When you create the field for worker, you can create an FK relation with HcmWorker which will store the RecId from HcmWorker table in the field. This will ensure that you get the default worker lookup On the form, this field will appear as a Reference group and you could then set the replacement field group pro.perty to "AutoIdentification".

    A good example is to look at  SalesTable\WorkerSalesResposible field. You can check the relations on this field and how it has been used in SalesTable form so that the worker name is displayed, based on user selection.

  • Ganesh Potnuru Profile Picture
    170 on at

    Hi Gunjan Bhattachayya

    I'm able to get that lookup with "Personnel Number" and "Worker Name" but while selecting personnel number is displaying in my custom field and I have tried the method you have suggested foreign key relation by using that I'm getting lookup but no value is displaying in my custom field after selection.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ganesh,

    I understood that and hence was suggesting a change in design. Is this a field in a table for which you are creating the lookup?

  • Ganesh Potnuru Profile Picture
    170 on at

    Thanks Gunjan Bhattachayya

    I got it, I used this onlookup event

    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();

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 678 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 283 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans