在Dynamics 365中将SSRS报告下载为PDF(按钮单击时)时,不会检索内容

时间:2017-11-09 09:17:34

标签: javascript pdf reporting-services dynamics-crm-2013 dynamics-crm-online

我想在按钮点击下载PDF格式的报告。但是当我调试我的代码时。不检索报告的内容。我只是得到一个HTML文件

我的代码:



callingMethod = function () {
debugger;
var params = getReportingSession();
var newpth = Xrm.Page.context.getClientUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] + "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] + "&OpType=Export&FileName=" + reportName + "&ContentDisposition=OnlyHtmlInline&Format=PDF";
window.open(newpth, "_self");
}
getReportingSession = function () {
var selectedIds = Xrm.Page.data.entity.getId();
var reportName = "AccountOverview.rdl";
var reportGuid = "2b2a692e-7d04-e711-80e6-00155db8652a";
var pth = Xrm.Page.context.getClientUrl() + "/crmeports/viewer/viewer.aspx";
var retrieveEntityReq = new XMLHttpRequest;
var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>< entity name= 'account' > <all-attributes/><filter type='and'><condition attribute='accountid' operator='eq' value='" + selectedIds + "' /></filter></entity ></fetch >";
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&p:CRM_AccountID=" + fetchXML);

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(x + 10, 32);
return ret;
}
&#13;
&#13;
&#13;

调试代码时的屏幕截图

Screenshot while debugging the code

1 个答案:

答案 0 :(得分:0)

在var newpth中,设置"ContentDisposition=AlwaysInline"。它应该工作。