Announcements
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?
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.
The link i posted is the one that answered my question.
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.
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".
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
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.
André Arnaud de Cal...
294,075
Super User 2025 Season 1
Martin Dráb
232,858
Most Valuable Professional
nmaenpaa
101,158
Moderator