web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to Create query in X++ by code to get only selected fields ?

(0) ShareShare
ReportReport
Posted on by 1,010

Hi All,

I want to create a query using X++ code to get only two fields Dataarea and Name from CompanyInfo Table  in the lookup. there are many fields in table and all are coming.

Class declaration code :-

SysLookupMultiSelectCtrl msctrl;
Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;

Form Init method code :-

super();
// mzkCompanyId - Name of control on which you want a lookup.
// CompanyInfo - Table name to get the lookup data
q = new Query();
qbd = q.addDataSource(TableNum(CompanyInfo));

msCtrl = SysLookupMultiSelectCtrl::constructWithQuery(element, mzkCompanyId,q);

In this code, I just want to show Dataarea and Name field

how to achieve it ?

*This post is locked for comments

I have the same question (0)
  • D.K.S. Profile Picture
    1,010 on at
    RE: how to Create query in X++ by code to get only selected fields ?

    Hi ievgen Miroshnikov,

    Thanks. it worked for me.

    Regards,

    DKS

  • Verified answer
    Mea_ Profile Picture
    60,284 on at
    RE: how to Create query in X++ by code to get only selected fields ?

    Hi D.K.S.,

    To specify fields you need to clear all fields from query and add only 2 you want, please refer for details theinfolog.com/using-a-query-with-syslookupmultiselectctrl

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans