Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Calling CRM Report from JS

(1) ShareShare
ReportReport
Posted on by

Hi, 

In my solution, I have a button on record. When I click to that button it must call a CRM Report and download the pdf of the current records report data. 

There are many solutions on the internet, how to do this with custom SSRS (such as the creation of parameter, which will take the GUID of the record). But I don't want to do it with 3rd party tools, I want to achieve this with CRM Report wizard, but I can't find where I can create the parameter for the report. How can I achieve this without creating an SSRS report, is there any alternative way?

P.S. I can call the report and download .pdf file for all records in the entity. Just need somehow pass the GUID of the record.

Here is the code which forks for all records...

var reportName = "Test.rdl";
var reportGuid = "8ebc1acd-913a-e511-80f8-c4346bad559c";
var recordGuid= "87ED34AD-8FE9-E811-A99E-000D3A81EC09";
var pth = "https://********.com/CRMReports/rsviewer/reportviewer.aspx";


var retrieveEntityReq = new XMLHttpRequest();


    retrieveEntityReq.open("POST", pth, false);

    retrieveEntityReq.setRequestHeader("Accept", "*/*");

    retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    retrieveEntityReq.send("id=%7B" + reportGuid + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName="+ reportName +"&isScheduledReport=false");

	
     var x = retrieveEntityReq.responseText.lastIndexOf("ReportSession=");
     var y = retrieveEntityReq.responseText.lastIndexOf("ControlID=");

	var ret = new Array();

        ret[0] = retrieveEntityReq.responseText.substr(x + 14, 24);
        ret[1] = retrieveEntityReq.responseText.substr(y + 10, 32);


	      var newPth = Xrm.Page.context.getClientUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + ret[0] + "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + ret[1] + "&OpType=Export&FileName=public&ContentDisposition=OnlyHtmlInline&Format=PDF";

		window.open(newPth, "_self");



Thanks in advance.

  • Suggested answer
    Jeevarajan Kumar Profile Picture
    773 Most Valuable Professional on at
    RE: Calling CRM Report from JS

    Hi,

    Parameters can't be passed to the report wizard. It has to be a SSRS report.

    ankit.inkeysolutions.com/.../dynamics-crm-2011-limitations-of-report.html

  • Community Member Profile Picture
    on at
    RE: Calling CRM Report from JS

    Nobody knows how to solve this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans