Skip to main content

Notifications

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 582

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

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Adding ranges to table methods in look up

    Have you solved the issue?

    Thanks,

    Girish S.

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: Adding ranges to table methods in look up

    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.

  • D365  beginner Profile Picture
    582 on at
    RE: Adding ranges to table methods in look up

    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,825 Moderator on at
    RE: Adding ranges to table methods in look up

    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.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans