
Good afternoon.
Our clients need to create word template document from MS Dynamics CRM of invoice sub-grid on order form. On standart, system create word template of last record in subgrid, when we have secord or more records in subgrid. How we can create invoice template from selected row in subgrid?
*This post is locked for comments
I have the same question (0)create ssrs report,
ReportName - ssrs report name
ReportId -ssrs reort guid
Format - pdf, excel,..
Filter - selected record entity id
function RenderReport(ReportName, ReportId, Format, Filter) {
var params = getReportingSession(ReportName, ReportId, Filter);
getReportFormatOutput(params, Format, ReportName);
}
function getReportingSession(ReportName, ReportId, Filter) {
var pth = Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/QuirksReportViewer.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" + ReportId + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName=" + ReportName + "&isScheduledReport=false&p:Id=" + Filter);
var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
var ret = new Array();
ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("\\u0026", x) - x - 14); //the session id
x = retrieveEntityReq.responseText.indexOf("ControlID=");
ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("\\u0026", x) - x - 10); //the control id
return ret;
}
function getReportFormatOutput(params, Format, ReportName) {
bdy = new Array();
bdyLen = 0;
var retrieveEntityReq = new XMLHttpRequest();
outputURL = 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";
var pth = outputURL + "&Format=" + Format;
retrieveEntityReq.open("GET", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.send();
var result = retrieveEntityReq.responseText;
//Display report output in HTML
document.getElementById("reportoutput").innerHTML = result;
}
Please mark the answer as verified if it was helpful.