Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

SRSReportServerWarmup - Setting dynamic parameter value(s)

(0) ShareShare
ReportReport
Posted on by 4,070

I am adding several reports to the SRSReportServerWarmup class to help speed up reports that are run [nearly] every day.  One of the reports requested to be added to the warmup list is the Purchase receiving log report (VendPurchReceivingLog_NA).  This report has no RDP, so I copied the "runSampleRdlReportWithParameters" method, as I want to add a value to the Delivery Date parameter and run it for the past 30 days.  However, this report runs from a view, which pulls from a query that has the DeliveryDate and PurchId dragged into the Range field, which automatically pulls these to the front when running the report for a user to select.  While the fields are displayed for entry, they are not hard-fast "parameters".  They are included in the AX Dynamic parameter "VendPurchReceivingLog_DynamicParameter".  

So, using the provided sample code:

   // Set any required parameter values here by first getting the report contract.

   contract = controller.parmReportContract();

   // And then fill in that contract based on the contract type (Rdl or Rdp)

   // Create the Rdl contract and set parameter values

   rdlDataContract = contract.parmRdlContract();

   rdlDataContract.setValue('<Parameter1Name>', '<Parameter1Value>');

   rdlDataContract.setValue('<Parameter2Name>', '<Parameter2Value>');

...how can I add in my DeliveryDate parameter into the dynamic parameter?  

*This post is locked for comments

  • Verified answer
    Andy Adamak Profile Picture
    4,070 on at
    RE: SRSReportServerWarmup - Setting dynamic parameter value(s)

    After some research and trial & error, I've found a solution.  You can add dynamic parameter values to a report in X++ using the method below.  It can be pasted into the SRSReportServerWarmup Class to be used like the other 'runSample' methods.  Just copy the code and replace the appropriate fields under the "// Retrieve the query map and set dynamic parameter values" section.  Note that if the datasource is not found on the query the report will still execute with no parameters.  Handling this situation could vary by report, so handle it on a per-report basis.  

    /// <summary>

    /// Sample method for running a simple report (non-RDP) that requires dynamic parameter values.

    /// </summary>

    /// <remarks>

    /// Use this method as a template for "warming-up" any simple SQL Server Reporting Services report.

    /// </remarks>

    public void runSampleReportWithDynamicParameters()

    {

       str reportFilePath;

       Map                             queryContracts;

       MapEnumerator                   meQueryContracts;

       Query                           currentQuery;

       QueryBuildDataSource            dataSource;

       SrsReportDataContract contract;

       SrsReportRdlDataContract rdlDataContract;

       // Create a controller to run the report.

       SrsReportRunController controller = new SrsReportRunController();

       // set the report name and design to be run

       controller.parmReportName('SampleReportName.DesignName');

       // suppress the parameter dialog as this is to be run by the batch service

       controller.parmShowDialog(false);

       // choose to save the executed report as a pdf file

       reportFilePath = System.IO.Path::Combine(this.getTempPath(), 'SampleReportName.DesignName' + #FileExtensionPDF);

       this.setReportRunControllerPrintToFile(controller, reportFilePath);

       // Set any required parameter values here by first getting the report contract.

       contract = controller.parmReportContract();

       // Retrieve the query map and set dynamic parameter values

       queryContracts = contract.parmQueryContracts();

       if(queryContracts)

       {

           meQueryContracts = queryContracts.getEnumerator();

           while(meQueryContracts.moveNext())

           {

               currentQuery = meQueryContracts.currentValue();

               dataSource = currentQuery.dataSourceName("VendPurchReceivingLog_NA");

               if(dataSource)

               {

                   SysQuery::findOrCreateRange(dataSource,fieldNum(VendPurchReceivingLog_NA, DeliveryDate))

                             .value(date2StrXpp(systemDateGet()) + '..'

                                   + date2StrXpp(DateTimeUtil::date(DateTimeUtil::addDays(DateTimeUtil::utcNow(), -30))));

               }

               else

               }

                   // ???

               }

           }

       }

       // run the report

       controller.runReport();

    }

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 46

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans