locked
SSRS Pass filter parameters using javascript RRS feed

  • Question

  • I'm trying to pass parameters to the ssrs report using javascript...

    below is the sample code ... t1 is the parameter and 1 as value.

    var params = getReportingSession(reportName, reportId, recordId, recordName, orgName); var pdfPath = "http://######" + "/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=" + fileType + ""; window.open(pdfPath, "", ""); function getReportingSession(reportName, reportId, recordId, recordName, orgName) { var pth = "http://######" + "/CRMReports/rsviewer/reportviewer.aspx?t1=1"; var filter = "<ReportFilter><ReportEntity paramname='P1' displayname='abc'><fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='ds_abc'><all-attributes/><filter type='and'><condition attribute='ds_abcid' operator='eq' uitype='ds_abc' value='" + recordId + "'/></filter></entity></fetch></ReportEntity></ReportFilter>"; var reportURL = "id=" + reportId + "&uniquename=" + orgName + "&iscustomreport=true&reportnameonsrs=&isScheduledReport=false&CRM_Filter=" + filter; //+"&reportName=" + reportName var retrieveEntityReq = new XMLHttpRequest(); retrieveEntityReq.open("POST", pth, false); retrieveEntityReq.setRequestHeader("Accept", "*/*"); retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); retrieveEntityReq.send(reportURL); var x = retrieveEntityReq.responseText.indexOf("ReportSession="); var ret = new Array(); ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id x = retrieveEntityReq.responseText.indexOf("ControlID="); ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id return ret; }

     getReportingSession method returning -1

    • Edited by Vijji MSL Monday, October 28, 2013 12:43 PM
    Monday, October 28, 2013 12:36 PM