Announcements
Hi Experts,
I need to apply a range in a table method in my code below. How can I achieve it in AX lookup method? In the table HcmWorker I don't have the field reportToWorker instead I have a method named reportToWorker returning the value and I have to add range here to match with my field MyTable.PersonReportTo.
public void lookup(FormControl _formControl,str _filterstr)
{
SysTableLookup sysTableLookup;
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange1;
HcmWorker hcmWorker;
;
sysTableLookup = sysTableLookup::newParameters(tablenum(hcmWorker),_formControl);
sysTableLookup.addLookupfield(fieldnum(hcmWorker,PersonnelNumber));
sysTableLookup.addLookupMethod(tableMethodStr(hcmWorker,Name));
queryBuildDataSource = query.addDataSource(tablenum(hcmWorker));
queryBuildRange1 = queryBuildDataSource.addRange(fieldNum(hcmWorker,reportToWorker()));
queryBuildRange1.value(MyTable.PersonReportTo);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Have you solved the issue?
Thanks,
Girish S.
Then you need to join HcmWorker, HcmPositionWorkerAssignment and HcmPosition table.
Relation will be HcmWorker.RecId == HcmPositionWorkerAssignment .Worker and
HcmPositionWorkerAssignment .Position == HcmPosition.RecId.
Thanks,
Girish S.
Thank you Girish for your quick response.
In that case how can I link these two tables ? reportToWorker method is taking value from HCMPositiontable and the look up fields are needed from HcmWorkerTable.
Hi AX Beginner,
You cannot add the range to the table method. Instead you need to add the table that is used in the reportToWorker method to the lookup query and add range to that.
Thanks,
Girish S.
André Arnaud de Cal...
294,099
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator