How to get the underlying SSRS Report Query, reset query , add your own ranges and execute report [AX2012]
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 AX6_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(); } }