web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create word template from selected row in sub-grid

(0) ShareShare
ReportReport
Posted on by

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)
  • Suggested answer
    Community Member Profile Picture
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans