Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

AX 2012 Multi table lookup

(0) ShareShare
ReportReport
Posted on by 480

I'm trying to come up with a lookup that fetches PositionId from HcmPosition and join it with the Description from HcmPositionDetail joining with RecId from HcmPosition and Position from HcmPositionDetail but am failing. I've created a view first which comprise of HcmPosition and HcmPositionDetail ON HcmPosition.RecId = HcmPositionDetail.Position but yielding wrong results. Also tried the following code.

Query query = new Query();
QueryBuildRange queryBuildRange;
QueryBuildDataSource qbds, Qbds1, Qbds2;
SysTableLookup sysTableLookUp;


sysTableLookUp = SysTableLookup::newParameters(tableNum(HcmPosition), _formControl);
qbds = query.addDataSource(tableNum(HcmPosition));
Qbds1 = qbds.addDataSource(tableNum(HcmPositionDetail));
Qbds1.addLink(fieldNum(HcmPosition, RecId), fieldNum(HcmPositionDetail, Position));
Qbds1.joinMode(JoinMode::InnerJoin);
Qbds1.relations(true);

//Qbds2 = qbds1.addDataSource(tableNum(HcmPositionDetail));
//Qbds2.addLink(fieldNum(HcmPosition, RecId), fieldNum(HcmPositionDetail, Position));
////Qbds1.fetchMode(QueryFetchMode::One2Many);
//Qbds2.joinMode(JoinMode::InnerJoin);
//Qbds2.relations(true);

sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(HcmPosition, PositionId));
sysTableLookup.addLookupfield(fieldNum(HcmPositionDetail, Description));
//sysTableLookup.addLookupfield(fieldNum(HcmPosition, NameAlias));
sysTableLookup.performFormLookup();

Anyone with the idea how i can go about it?

  • Martin Dráb Profile Picture
    232,858 Most Valuable Professional on at
    RE: AX 2012 Multi table lookup

    All right then. Just please mark the verified answer.

    By the way, the link I gave you contains not only the link to the .xpo, but also explanation from the author.

  • Huggins Mafigu Profile Picture
    480 on at
    RE: AX 2012 Multi table lookup

    The link i posted is the one that answered my question.

  • Huggins Mafigu Profile Picture
    480 on at
    RE: AX 2012 Multi table lookup

    Yes wanted to achieve the same thing on two different environments. So I decided to have my question asked on the lower version of the two environments in which i want to work on. Two birds on one stone thing.

  • Martin Dráb Profile Picture
    232,858 Most Valuable Professional on at
    RE: AX 2012 Multi table lookup

    Does it mean that you question is answered? If so, please verify it (using Did this answer your question? > Yes).

    I'm also surprised that you want something in D365FO, since this thread is clearly about AX 2012 (it's in the AX forum, the version tag is "Microsoft Dynamics AX 2012" and even the title is prefixed with "AX 2012".

  • Suggested answer
    Huggins Mafigu Profile Picture
    480 on at
    RE: AX 2012 Multi table lookup

    Thanks @Martin Drab, I had found a SysMultiTableLookUp xpo  which I imported into AX 2012 and now working on a work around for it to work in D365 FinOp

    www.axaptapedia.com/.../PrivateProject_SysMultiTableLookup.xpo

  • Verified answer
    Martin Dráb Profile Picture
    232,858 Most Valuable Professional on at
    RE: AX 2012 Multi table lookup

    You code can't work. This line:

    sysTableLookup.addLookupfield(fieldNum(HcmPositionDetail, Description));

    means: "add a field from HcmPosition table that has the same ID as Description field has in HcmPositionDetail table". It's clearly not what you want.

    Either use SysMultiTableLookup or create a view that will return fields from both tables.

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,075 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,858 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans