Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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 

*This post is locked for comments

  • 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
    Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 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.

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 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

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