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.