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 run a Query in AX 7 from outside AX, i.e. from an external Application?

(0) ShareShare
ReportReport
Posted on by 792

Hi all,

In AX 2012:-

I use to create a query (say fetch Company Info from Datasource CompanyInfo_DS) in AOT and then create a View and add that query inside the Metadata section of that View and when I run that View, it gives me the entire query result. Then I make use of a particular AIF service called QueryService to execute the query.

But in AX 7:-

There is no QueryService as there is no AIF service. Also in the View, I cannot add the Query in the Metadata section, hence I cannot check in the Appl Explorer whether the Query returns proper result.

Also I have read in a blog that, in AX 7 QueryService is replaced by OData service.

Can you guide me in how to run a Query from an external application (say a Console Application) using the OData service?

I have learnt to create a Data Entity, and set its IsPublic property to true to make it OData compatible. But I don't know how to set up a Query to be compatible or called with an OData service in AX7.

Please help.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Hi Sagnik Majumder,

    You can use web browser, build console application or open it in Excel. Please read this blog post for details community.dynamics.com/.../ax-7-rtw-my-odata-and-json-journey-part-i

  • Sagnik Majumder Profile Picture
    792 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Hi Ievgen,

    Thank you for your reply. I am aware of this approach of getting query results which are already exposed as OData service from the Browser or Console application.

    But what I need is for custom-made Queries.

    Suppose if I create a Query, say GetCompanyInfo, which lists the information of all companies available. Now how to expose it as a OData Service? If it can be exposed as a OData service, I guess it can be fetched from Browser as well as Console app.

  • Verified answer
    Mohd saddaf khan Profile Picture
    20 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    I believe you already know how to create Data entity.

    Data entities exposes data following standard Odata protocols and supports CRUD(create, read, update and delete) operations.

    You have a option to define some logic directly on data entities during creation or You can simply use Odata querying options as defined above.

    I would suggest you to go through the link to get more detailed information on data entities

    ax.help.dynamics.com/.../data-entities-home-page  

  • Sagnik Majumder Profile Picture
    792 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Yes I know Data Entities.

    So are you suggesting that if I want to create a Query and execute it from outside AX, I do it through Data Entities?

    I thought Data Entities are used to replace Document Services of AX 2012. Has it replaced QueryService as well?

    So will I create a Data Entity for each Query that I want to create and then expose it as OData and then only can I fetch the result?

  • Verified answer
    Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Yes - you even said it by yourself above: "Also I have read in a blog that, in AX 7 QueryService is replaced by OData service".

  • Sagnik Majumder Profile Picture
    792 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Hi Martin,

    Yes, I am a bit confused with this. I read that in AX 7 QueryService is replaced by OData service, whereas Document Services (AXDs) are replaced by Data Entities. So I thought I don't have to create Data Entities for creating and executing a query.

    But I guess without creating Data Entities, you cannot expose anything as OData service. Am I right?

    Also another thought: Why is the "Queries" node still present in the Appl Explorer, when all you need to do if you want to create a query, is, only create Data Entities on the proper datasources and expose it as Odata service and call it from outside?

  • Verified answer
    André Arnaud de Calavon Profile Picture
    299,260 Super User 2025 Season 2 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Hi Sagnik,

    Data Entities is the layer between data storage and internal or external communications. Data migration and also OData is using this layer. So you are on the correct path now.

    Queries are still used in x++ logic, forms etc. A query is not intended to be public.

  • Sagnik Majumder Profile Picture
    792 on at
    RE: How to run a Query in AX 7 from outside AX, i.e. from an external Application?

    Yes, Data Entities worked like a charm in executing my query!!

    It also answers that for any external communication with AX, Data Entities is the key.

    Thanks all for leading me to the correct direction.

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 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans