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

Announcements

No record found.

News and Announcements icon
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 172

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
    172 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
    172 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

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans