Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to fetch SQL query from AOT Objects

Posted on by Microsoft Employee

Hi,

  I am trying to extract the SQL query from AOT Object(smmSalesCustItemStatistics) in MS Dynamic AX 2012 R3.

Please help me by providing step by step guidance to extract it. I am new starter for Dynamics and have started a week ago,so I don't have much knowledge about this stuff. Please provide me the code which will help me to extract the SQL Query .

Thanks 

Categories:
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to fetch SQL query from AOT Objects

    Thanks a lot Sohaib. I figured out what was my mistake. Really appreciate your help here.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to fetch SQL query from AOT Objects

    I am getting the following error when I am running the following job

    static void ExecuteAOTQueryCust_5MSC(Args _args)

    {

        QueryRun queryRun;

        ;

        queryRun = new QueryRun(queryStr(CustTable));

        info(queryRun.query().dataSourceTable(tablenum(CustInvoiceJour)).toString());

    }

    Error executing code: QueryBuildDataSource object not initialized.

    Stack trace

  • Verified answer
    sohaibcheema Profile Picture
    sohaibcheema 46,594 User Group Leader on at
    RE: How to fetch SQL query from AOT Objects

    Its a job, x++ job. Create a new job in AOT and paste the code there.

    Then read the code and change query name from CustTable to your needed query name such as smmSalesCustItemStatistics

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to fetch SQL query from AOT Objects

    Thanks for the reply.

    Can you tell me where to write the following code.

    static void ExecuteAOTQueryCust_1SMC(Args _args)

    {

        QueryRun queryRun;

        ;

        queryRun = new QueryRun(queryStr(CustTable));//add any name of query here

        info(queryRun.query().toString());

    }

    I have opened the CustTable and seeing Methods,DataSources,Dependent Objects and so on . But  don't know where to write the above piece of code.

  • sohaibcheema Profile Picture
    sohaibcheema 46,594 User Group Leader on at
    RE: How to fetch SQL query from AOT Objects

    you may not get 100% pure sql syntax but very close picture can be taken by some x++ jobs. have a look at next post

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,252 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,089 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans