Announcements
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.
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();
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?
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.
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.
André Arnaud de Cal...
293,304
Super User 2025 Season 1
Martin Dráb
232,149
Most Valuable Professional
nmaenpaa
101,156
Moderator