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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

How to fetch SQL query from AOT Objects

(0) ShareShare
ReportReport
Posted on by

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 

*This post is locked for comments

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

    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

  • Community Member Profile Picture
    on at

    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.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,496 User Group Leader on at

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

    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

  • Community Member Profile Picture
    on at

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

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

News and Announcements

Season of Giving Solutions is Here!

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#3
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans