
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
I have the same question (0)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();
}