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, ...
Suggested Answer

Adding ranges to table methods in look up

(0) ShareShare
ReportReport
Posted on by 634

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

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    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.

  • D365  beginner Profile Picture
    634 on at

    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.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    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.

  • GirishS Profile Picture
    27,827 Moderator on at

    Have you solved the issue?

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