Setting SSRS report parameters as optional in D365FO
Hi,
Please refer to my earlier post to view the report SSRSPrecisionDesign related classes, tables and menu Item.
Tables: SampleTable and SampleTrans
In this post, we will try set the parameters Id, Start date and End date as optional.
Step 1: In the report project, open the report and for the parameter SSRSReportDP_Id set the properties AllowBlank and Nullable to True. Similarly set the same properties for other parameters SSRSReportDP_StartDate and SSRSReportDP_EndDate.
Step 2: In the processReport method of the data provider class SSRSReportDP modified the code such that the ranges are added to the report query only if the parameters have value.
/// <summary> /// Retrieves records based on the parameters entered. /// </summary> public void processReport() { QueryRun queryRun; Query query; QueryBuildDataSource qbdsSampleTable, qbdsSampleTrans; QueryBuildRange qbrDueDate; SSRSReportContract contract; StartDate startDate; EndDate endDate; SampleTableId id; contract = this.parmDataContract() as SSRSReportContract; id = contract.parmId(); startDate = contract.parmStartDate(); endDate = contract.parmEndDate();query = this.parmQuery(); qbdsSampleTable = query.dataSourceTable(tableNum(SampleTable)); if (id != "") { SysQuery::findOrCreateRange(qbdsSampleTable, fieldNum(SampleTable, Id)).value(queryValue(id)); }if (startDate != dateNull() && endDate != dateNull()) { SysQuery::findOrCreateRange(qbdsSampleTable, fieldNum(SampleTable, DueDate)).value(queryRange(startDate, endDate)); }queryRun = new QueryRun(query);while (queryRun.next()) { sampleTable = queryRun.get(tablenum(SampleTable)); sampleTrans = queryRun.get(tablenum(SampleTrans));this.insertSSRSReportTableTmp(); } }Step 3: Build the solution and generated the report.
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments