How to Open Report by using URL

Reports can be viewed by using Dynamics 365 report viewer. But sometimes we need to open a specific report from other applications referring to the report server reports or Dynamics 365 reports. SO for this scenario we can open report using the below methods.

We can open a report by passing appropriate parameter values to the below URL:

[organization url]/crmreports/viewer/viewer.aspx

This URL accepts the following parameters:

action
Two possible values for this parameter are run or filter. When run is used, the report will be displayed using the default filters. When filteris used, the report will display a filter that the user can edit before choosing the Run Report button to view the report.
helpID
This parameter is optional. For reports that are included with Microsoft Dynamics 365 the value in this parameter allows the Help button to display appropriate content about this report when Help on This Page is chosen. The value should correspond to the report FileNameattribute value.
id
This parameter is the report ReportId attribute value.

Sample URL to open the Top Knowledge Base Articles report and prompt the user to set filter values is given below:

[organization url]/crmreports/viewer/viewer.aspx?action=filter&helpID=Top%20Knowledge%20Base%20Articles.rdl&id=%7bd84ec390-7839-e211-831e-00155db7d98f%7d

Sample URL to open the Neglected Cases report using the default filter is given below:

[organization url]/crmreports/viewer/viewer.aspx?action=run&helpID=Neglected%20Cases.rdl&id=%7b8c9f3e6f-7839-e211-831e-00155db7d98f%7d

A sample function to return Report URL :

Function Definition

function getReportURL(action,fileName,id) {
 var orgUrl = GetGlobalContext().getClientUrl();
 var reportUrl = orgUrl + 
  "/crmreports/viewer/viewer.aspx?action=" +
  encodeURIComponent(action) +
  "&helpID=" +
  encodeURIComponent(fileName) +
  "&id=%7b" +
  encodeURIComponent(id) +
  "%7d";
 return reportUrl;
}

Call Method

function OpenReport_OnButtonClick()
{
 var urltarget = getReportURL("run","Neglected Cases.rdl","8c9f3e6f-7839-e211-831e-00155db7d98f");
 window.open(urltarget);
}