Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Multi Table Lookup fields

(0) ShareShare
ReportReport
Posted on by 307

I want lookup for Item ID with Item Id and NameAlias coming from Invent table and Name from EcoResProductTranslation in lookup. 

Here is my lookup method but Name is not coming. 

Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;

SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(InventTable), this);
;

qbds = query.addDataSource(tableNum(InventTable));
QbdsJoin = qbds.addDataSource(tableNum(EcoResProductTranslation));
QbdsJoin.joinMode(JoinMode::InnerJoin);
QbdsJoin.fetchMode(QueryFetchMode::One2Many);
QbdsJoin.relations(true);
QbdsJoin.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProductTranslation, Product));
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldNum(EcoResProductTranslation,Name));
sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias));
sysTableLookup.performFormLookup();

*This post is locked for comments

  • Suggested answer
    Hossein.K Profile Picture
    Hossein.K 6,646 on at
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Multi Table Lookup fields

    There are many ways to do it although I found a easiest way to do it here is the link for multi table look:

    1. Single Table Lookup with Multiple Table: Mutli Table Lookup - Single Table Lookup with Multiple Table

    2. Multiple Table Lookup With Multiple Table: Multi Table Lookup - Multiple Table Lookup With Multiple Table

    hope you find it useful :)

  • B K Sharma Profile Picture
    B K Sharma 735 on at
    RE: Multi Table Lookup fields

    Hi Prabakaran,

    Is the solution suggested by me is not ok, As i already told you that multi table field lookup not allowed using systablelookup class. Correct me if i am wrong.

    Thanks

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: Multi Table Lookup fields

    Hi,

    I could see a similar requirement at the below link and there is a suggestion to use SysMultiTableLookupClass

    https://dynamicsuser.net/ax/f/developers/66365/ax2012-r2-runtime-lookup-with-multiple-table

  • Prabakaran.R Profile Picture
    Prabakaran.R 307 on at
    RE: Multi Table Lookup fields

    Hi Chaitanya Golla ,

    2043.Untitled.png

    I tried with your code, instead  of getting item name, I 'm getting item type in look up.

    NOTE: I didn't mapped item type in lookup.    

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: Multi Table Lookup fields

    Hi,

    I tested your code in a job.Let me check it on a form lookup. Please replace your code with below statements and try once.

    sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));
       sysTableLookup.addLookupfield(fieldNum(EcoResProductTranslation,Name), true);    
       //sysTableLookup.addSelectionField(fieldNum(EcoResProductTranslation,Name));
       sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias));   
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
  • Prabakaran.R Profile Picture
    Prabakaran.R 307 on at
    RE: Multi Table Lookup fields

    Hi Chaitanya Golla,

       I tried with this code, but still the Name from EcoResProductTranslation is not coming in lookup.

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: Multi Table Lookup fields

    Please use the following code

    qbds = query.addDataSource(tableNum(InventTable));
       Qbds1  = qbds.addDataSource(tableNum(EcoResProduct));
       Qbds1.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProduct, RecId)); 
       Qbds1.joinMode(JoinMode::InnerJoin);
       Qbds1.relations(true);
        
       Qbds2  = qbds1.addDataSource(tableNum(EcoResProductTranslation));
       Qbds2.addLink(fieldNum(EcoResProduct, RecId), fieldNum(EcoResProductTranslation, Product));
       //Qbds1.fetchMode(QueryFetchMode::One2Many);
       Qbds2.joinMode(JoinMode::InnerJoin);
       Qbds2.relations(true);
       
       sysTableLookup.parmQuery(query);
       sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));
       sysTableLookup.addSelectionField(fieldNum(EcoResProductTranslation,Name));
       sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias));
       sysTableLookup.performFormLookup();     
  • Prabakaran.R Profile Picture
    Prabakaran.R 307 on at
    RE: Multi Table Lookup fields

    Hi Crispin John Augustine ,

    I gave the inner join between InventTable--EcoResProduct-EcoResProductTranslation  but still the Name from EcoResProductTranslation is not coming lookup.

    qbds = query.addDataSource(tableNum(InventTable));

       Qbds1  = qbds.addDataSource(tableNum(EcoResProduct));

       Qbds2  = qbds1.addDataSource(tableNum(EcoResProductTranslation));

       Qbds1.joinMode(JoinMode::InnerJoin);

       //Qbds1.fetchMode(QueryFetchMode::One2Many);

       Qbds1.relations(true);

       Qbds2.joinMode(JoinMode::InnerJoin);

       Qbds2.relations(true);

       Qbds1.addLink(fieldNum(InventTable, Product), fieldNum(EcoResProduct, RecId));

       Qbds2.addLink(fieldNum(EcoResProduct, RecId), fieldNum(EcoResProductTranslation, Product));

       sysTableLookup.parmQuery(query);

       sysTableLookup.addLookupfield(fieldNum(InventTable, ItemId));

       sysTableLookup.addSelectionField(fieldNum(EcoResProductTranslation,Name));

       sysTableLookup.addLookupfield(fieldNum(InventTable, NameAlias));

       sysTableLookup.performFormLookup();                

  • Suggested answer
    B K Sharma Profile Picture
    B K Sharma 735 on at
    RE: Multi Table Lookup fields

    follow link to get exact solution you want step by step.

    https://community.dynamics.com/ax/b/daxbeginners/archive/2014/05/20/how-to-create-form-lookup-lookup-multiple-tables

    Thanks

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans