✏️ Explanatory Question

How do you implement parameter validation in SSRS reports in D365 Finance & Operations?

👁 15 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

In D365FO SSRS reports, parameter validation is implemented in the Data Contract class by making it implement the SysOperationValidatable interface and writing the validation logic in the validate() method.

The validate() method runs when the user clicks OK on the report dialog. If validation fails, checkFailed() is used to show an error message and stop the report from executing. This approach is best practice because it validates parameters before data processing begins.

Example use cases include:

  • Preventing blank Start Date or End Date

  • Ensuring End Date is not earlier than Start Date

This method ensures clean design, better user experience, and avoids unnecessary report execution.

Example – Date range validation


[DataContract]
class SSRSReportContract implements SysOperationValidatable
{
    FromDate startDate;
    ToDate   endDate;

    [DataMember]
    public FromDate parmStartDate(FromDate _startDate = startDate)
    {
        startDate = _startDate;
        return startDate;
    }

    [DataMember]
    public ToDate parmEndDate(ToDate _endDate = endDate)
    {
        endDate = _endDate;
        return endDate;
    }

    public boolean validate()
    {
        boolean isValid = true;

        if (startDate == dateNull())
        {
            isValid = checkFailed("Start date cannot be blank.");
        }
        else if (endDate == dateNull())
        {
            isValid = checkFailed("End date cannot be blank.");
        }
        else if (startDate > endDate)
        {
            isValid = checkFailed("End date must be later than start date.");
        }

        return isValid;
    }
}

Result:

  • Validation runs before report execution

  • Error message is shown on the dialog

  • Report does not run until valid parameters are provided

Best practice: Use labels instead of hardcoded strings for production code.