Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to get the name of company?

Posted on by 920

Hi,

I have form like this : 

company.png

I want to display in lookup the name of  the

corresponding company,but get the id not the name.
this is lookup method :


query.allowCrossCompany(true);
sysTableLookup = SysTableLookup::newParameters(tableNum(EUKMatrixRole),this);
queryBuildDataSource = query.addDataSource(tableNum(EUKMatrixRole));
sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixID));
sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixName));
sysTableLookup.addLookupfield(fieldNum(CompanyInfo,Name));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(EUKMatrixRole, MatrixID));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

*This post is locked for comments

  • Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of company?

    But the question was about company name.

    BTW you can mark question as answered if it's done.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of company?

    Hi Rustem,

    I only display the dataAreaId so I don't need to display the name of company ,I use this

    query.allowCrossCompany(true);

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

           queryBuildDataSource = query.addDataSource(tableNum(EUKMatrixRole));

           //qbds=queryBuildDataSource.addDataSource(tableNum(CompanyInfo));

          //qbds.joinMode(JoinMode::InnerJoin);

          // qbds.relations(false);

          // qbds.addLink(fieldNum(EUKMatrixRole, DataAreaId), fieldNum(CompanyInfo,DataArea));

           queryBuildRange = queryBuildDataSource.addRange(fieldNum(EUKMatrixRole, MatrixID));

         //  sysTableLookup  = SysTableLookup::newParameters(this, query);

           sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixID));

           sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixName));

           sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole,DataAreaId));

           sysTableLookup.parmQuery(query);

           sysTableLookup.performFormLookup();

  • Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of company?

    Did you solve your issue?

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of company?

    Replace sysMultiTableLookup.addLookupfield(fieldNum(CompanyInfo,Name)) with sysMultiTableLookup.addLookupfield(fieldNum(CompanyInfo,Name), 2).

    2 - it's a num of query's data source.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of company?

    I import the project,now i don't get the error but I don't show the value in lookup : 

    8838.info.png

    this is information about form : 

    8838.info.png

    this is the lookup ():

    SysTableLookup sysTableLookup;
    SysMultiTableLookup sysMultiTableLookup;

    if(radioButtonCreateFrom.selection() == EUKCreationMatrixType::FromMatrix)
    {

    query.allowCrossCompany(true);
    // sysTableLookup = SysTableLookup::newParameters(tableNum(EUKMatrixRole),this);
    queryBuildDataSource = query.addDataSource(tableNum(EUKMatrixRole));
    qbds=queryBuildDataSource.addDataSource(tableNum(CompanyInfo));
    qbds.joinMode(JoinMode::InnerJoin);
    qbds.relations(false);
    qbds.addLink(fieldNum(EUKMatrixRole, DataAreaId), fieldNum(CompanyInfo,DataArea));
    queryBuildRange = queryBuildDataSource.addRange(fieldNum(EUKMatrixRole, MatrixID));
    sysMultiTableLookup = SysMultiTableLookup::newParameters(this, query);
    sysMultiTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixID));
    sysMultiTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixName));
    sysMultiTableLookup.addLookupfield(fieldNum(CompanyInfo,Name));

    sysMultiTableLookup.parmQuery(query);
    sysMultiTableLookup.performFormLookup();
    }

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of company?

    SysMultiTableLookup class isn't a part of the standard application. It's published as open source. You should to download it from http://kashperuk.blogspot.com/2008/09/sysmultitableloookup-dynamic-lookups.html, import, compile and then you can use it in your code.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of company?

    Hi Rustem,

    this is the lookup method :

    public void lookup()

    {

       Query query = new Query();

       QueryBuildDataSource queryBuildDataSource,qbds;

       QueryBuildRange queryBuildRange;

      //SysTableLookup sysTableLookup;

      SysMultiTableLookup sysTableLookup;

       if(radioButtonCreateFrom.selection() == EUKCreationMatrixType::FromMatrix)

       {

           query.allowCrossCompany(true);

          //sysTableLookup = SysTableLookup::newParameters(tableNum(EUKMatrixRole),this);

           queryBuildDataSource = query.addDataSource(tableNum(EUKMatrixRole));

           qbds=queryBuildDataSource.addDataSource(tableNum(CompanyInfo));

           qbds.joinMode(JoinMode::InnerJoin);

           qbds.addLink(fieldNum(EUKMatrixRole, DataAreaId), fieldNum(CompanyInfo,DataArea));

           queryBuildRange = queryBuildDataSource.addRange(fieldNum(EUKMatrixRole, MatrixID));

           sysTableLookup  = SysMultiTableLookup::newParameters(this, query);

           sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixID));

           sysTableLookup.addLookupfield(fieldNum(EUKMatrixRole, MatrixName));

           sysTableLookup.addLookupfield(fieldNum(CompanyInfo,Name));

           sysTableLookup.parmQuery(query);

           sysTableLookup.performFormLookup();

          }

    But I have error when I declare   SysMultiTableLookup

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: How to get the name of company?

    Hi Basma!

    Just to add to ievgen suggestion, you can use custom SysMultiTableLoookup tool http://kashperuk.blogspot.com/2008/09/sysmultitableloookup-dynamic-lookups.html.

    This is example how to use it https://community.dynamics.com/365/financeandoperations/b/ax2012codingaxclated/archive/2014/07/14/multi-table-lookups-sysmultitablelookup

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to get the name of company?

    Hi ievgen,

    Thanks but I don't understand your suggestion

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to get the name of company?

    Hi BASMA,

    sysTableLookup does not support more than 1 datasource. There are 2 possible workarounds: use view that combines 2 tables as a datasource or create display method that returns data from second table and add it using sysTableLookup.addLookupMethod();

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans