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, ...
Answered

AX 2012 Multi table lookup

(0) ShareShare
ReportReport
Posted on by 509

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?

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    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.

  • Suggested answer
    Huggins Mafigu Profile Picture
    509 on at

    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

  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    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".

  • Huggins Mafigu Profile Picture
    509 on at

    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.

  • Huggins Mafigu Profile Picture
    509 on at

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

  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    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.

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
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans