Get the underlying SSRS Report Query, reset query , add your own ranges and execute report [Dynamics AX 2012, X++]

Friends,

Below is the small code snippet to get the underlying query of the SSRS report, reset query, prompt the parameters form, add our own ranges and execute the report. You can customize the job as per your requirements. Below I have used CustBaseData.Report report and added my own range on customer group.

static void SR_ResetQueries_executeReport(Args _args)

{

    #define.reportName(‘CustBaseData.Report’) // report Name

    QueryBuildRange queryBuildRange;

    QueryBuildDatasource queryBuildDatasource;

    SRSReportRun srsReportRun;

    Query reportRunQuery;

    srsReportRun = new SRSReportRun(#reportName);

    srsReportRun.init();

    srsReportRun.resetQueries(); // reset the query

    reportRunQuery = srsReportRun.reportQueries().lookup(srsReportRun.currentQueryKey());

    if (srsReportRun.isInitialized() && srsReportRun.prompt()) // prompt the parameters form

    {

        queryBuildDatasource = SysQuery::findOrCreateDataSource(reportRunQuery, tablenum(CustTable));

queryBuildRange = SysQuery::findOrCreateRange(queryBuildDatasource,  fieldnum(CustTable, CustGroup));

        queryBuildRange.value(‘INT’);

        queryBuildRange.status(RangeStatus::Hidden);

        srsReportRun.saveSettings();

        srsReportRun.executeReport();

    }

}

Happy Dax6ng,

Sreenath Reddy

 

About these ads

3 Responses to “Get the underlying SSRS Report Query, reset query , add your own ranges and execute report [Dynamics AX 2012, X++]”

  1. Hemal Shrimarkar Says:

    Hiii,
    Your articles are really excellent. I really admired about attitude of sharing.
    please share new idea with us:-dynamics ax consulting

  2. Hemal Shrimarkar Says:

    Thanks!!! Really you give great hint on Microsoft Dynamics AX Implementation… please share with us… I really like your blog, these information is very useful…

  3. dynamics ax consultancy Says:

    It is good to have the blogs like yours which are meaningful & have some information about the dynamic ax which is a popular stuff in terms of software. I even read your newly written blog about “How to display/show the inventory dimensions as parameters on SSRS reports [Dynamics AX 2012, X++]” which is also very nice & helpful to know about how to display the dimension as parameters. I am always looking forward to your blog so keep it continue so that we can get to know more about dynamic ax.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 212 other followers

%d bloggers like this: