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)

Download SQL based SSRS Report from button in pdf or Excel in dynamic CRM

(0) ShareShare
ReportReport
Posted on by 62

I am facing issue while downloading SQL based SSRS Reports from ribbon button, Its working fine when No parameters will added, but with parameters not worked. It may be because of missing the correct way to pass parameters, currently i'm downloading report using Javascript code. Please help ?

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    What happens if you add parameters ? Do you get an error, or are the parameters ignored ?

    Can you post an example of the request that you submit to download the report ?

  • ScottDurow Profile Picture
    21 on at

    You need to pass the parameters slightly differently depending on which approach you are using .

    I did a blog about this along time ago - www.develop1.net/.../Embedding-CRM-reports-in-IFrames-using-the-CRM2011-Report-Viewer.aspx

    Also see social.microsoft.com/.../passing-parameters-to-crm-reports-through-url

    Hope this helps

  • Community Member Profile Picture
    on at

    Hi Jasdeep, i use the logic below:

        //INI
        var retrieveEntityReq = new XMLHttpRequest();
        var clientUrl = Xrm.Page.context.getClientUrl();
        retrieveEntityReq.open("POST", clientUrl + "/CRMReports/rsviewer/reportviewer.aspx", 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:ngdId=" + ngdId +"&p:Preview=" + preview);
        //END
    
        console.log('gerou report!');
    
        //INI
        var firstIndexOfReportSession = retrieveEntityReq.responseText.indexOf("ReportSession=");
        var x = retrieveEntityReq.responseText.indexOf("ReportSession=", firstIndexOfReportSession + 3);
        var reportSession = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
        var firstIndexOfControlId = retrieveEntityReq.responseText.indexOf("ControlID=");
        x = retrieveEntityReq.responseText.indexOf("ControlID=", firstIndexOfControlId + 3);
        var controlId = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
        //END
    
        var fileName = escape(ngdId + " - " + customer + " - v.");
    
        //Generate URL
        var url = clientUrl +
            "/Reserved.ReportViewerWebControl.axd?ReportSession=" +
            reportSession +
            "&Culture=1046&CultureOverrides=True&UICulture=1046&UICultureOverrides=True&ReportStack=1&ControlID=" +
            controlId +
            "&OpType=Export&FileName=" +
            fileName +
            "&ContentDisposition=OnlyHtmlInline&Format=PDF";
    
        console.log(url);   
    
        //Report Download
        window.location.assign(url);


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