Handling validations on SSRS reports 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 see how to introduce custom validations that need to checked on the dialog, before generating report. Few validations are
on EndDate parameter - If it is less than start date then message would be "End date must be later than start date"
on EndDate parameter - If it is left blank and start date is specified then message would "End date cannot be blank, please provide some valid date."
on StartDate parameter - If it is left blank and end date is specified then message would be "Start date cannot be blank, please provide some valid date."
Step 1: Contract SSRSReportContract is modified such that it implements interface SysOperationValidatable
class SSRSReportContract implements SysOperationValidatableStep 2: Required validations are written under the new method validate.
/// <summary> /// Validates the contract. /// </summary> /// <returns> /// A Boolean value that indicates whether the contract is valid. /// </returns> public boolean validate() { boolean isValid = true;if (startDate == dateNull()) { isValid = checkFailed("Start date cannot be blank, please provide some valid date."); } else if (endDate == dateNull()) { isValid = checkFailed("End date cannot be blank, please provide some valid date."); } else { if (startDate > endDate) { isValid = checkFailed("End date must be later than start date"); } }return isValid; } Note: Please generate labels for the warning messages, for demo purpose they were left as-is.
Step 3: Build the solution and tried to generate the report by specifying blank value for start date. On click OK, we are getting a warning message stating "Start date cannot be blank, please provide some valid date". Report Output
Step 4: Tried to generate the report by specifying blank value for end date. On clicking OK, we are getting a warning message stating "End date cannot be blank, please provide some valid date". Report Output
Step 5: Tried to generate the report by specifying date value for end date which is less than start date. On clicking OK, we are getting a warning message stating "End date must be later than start date". Report Output
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments