SSRS is a powerful reporting tool for designing and managing reports, which can be created by connecting the various data sources, and it is a server-based reporting software platform which creates a rdl file.
SSRS focuses on the data that which is fetched and the way it is visualized in the report.
When a report is designed for Dynamics 365 CE, usually “Run Report” functionality is used to view the report output. But what if the client wants to view a designed report directly on a form in Dynamics 365 CE over Run Report function?
The way to achieve this,
In this example following is a small report which is going to be placed on a form. This is built by using Visual Studio 2015 with SSDT (SQL server data tools)
First, create a solution and create a new report using report wizard.
Next create a new web resource to place code.
Steps to show SSRS Report on the Form:
Open Solution and required Entity Form in form Properties,
- Insert IFrame On the Form.
- IFrame Properties -> provide about:blank in the URL field as shown below.
- Uncheck the Restrict Cross Frame Scripting
- Save the form.
- Publish the form.
Steps to add the code in the Web Resource:
- Copy the URL of the required Report starting from “crmreports”.
2. Use the above copied URL of the report in the below code with same format by providing the name of the iframe in code
//Code to add in the web resource, to show SSRS report on the form
function displayReport()
{
var iframeObject = Xrm.Page.getControl(“IFRAME_GRN_Report_for_Items_Count”);
if (iframeObject != null)
{
var strURL = “/crmreports/viewer/viewer.aspx?id=9657bdb4-496a-ed11-81ac-6045bdaadbfb&action=run&context=records&recordstype
=10330&records=” + Xrm.Page.data.entity.getId();
iframeObject.setSrc(strURL);
}
}
In the above code, Xrm.Page.data.entity.getId() is used to get the current record ‘guid’ to run SSRS report on every record.
3. Add Web resource as Library in the form properties in the same form where iFrame is added. Call the above function on required event handler.
Successfully able to see the SSRS report on the Form.