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 :
Microsoft Dynamics AX (Archived)

Multi Table Lookup fields

(0) ShareShare
ReportReport
Posted on by 313

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

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    it may be because InventTable has got no direct relationship with EcoResProductTranslation.

    you may need to include EcoResProduct in between two tables.

    please note that EcoResProductTranslation can have multiple records for same product based on different languages, so be careful or you might add a range to filter for a specific language such as EN-US or EN-UK or whatever language is of your region. also you can take language from user options of current user.

  • Suggested answer
    B K Sharma Profile Picture
    737 on at

    Dear Prabakaran,

    There is not possible to use multi table field in custom lookup method, but you can use these fields in lookup using view, just create a view and use it as datasource in the lookup method.

    Also request you to please complete the thread in this group started by you, either you got solution by your own or you got solution from anywhere, pls mark all this in your thread which was initialized by you, it will become helpful for other user who got same type of problems in there development.

    Thanks

  • Suggested answer
    B K Sharma Profile Picture
    737 on at

    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

  • Prabakaran.R Profile Picture
    313 on at

    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
    Chaitanya Golla Profile Picture
    17,225 on at

    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
    313 on at

    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
    17,225 on at

    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
    313 on at

    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
    17,225 on at

    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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans