Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Button Click Download Report as Pdf Format

Posted on by 1,345

Hi,

  i am working on Dynamics 365 online , i have to download custom report as pdf format on Button click how to achieve this please guide me to do this.

Thanks and Regards,

Iswarya.

*This post is locked for comments

  • Suggested answer
    ARIFNIIT Profile Picture
    ARIFNIIT 1,391 on at
    RE: Button Click Download Report as Pdf Format

    Refer below article

    docs.microsoft.com/.../exporting-to-microsoft-word-report-builder-and-ssrs

  • Seenivasan M Profile Picture
    Seenivasan M 305 on at
    RE: Button Click Download Report as Pdf Format

    Hi Mohammad Arif,

    Thank you for your response.

    I want to download the SSRS Report as Word document on button click.

  • Suggested answer
    ARIFNIIT Profile Picture
    ARIFNIIT 1,391 on at
    RE: Button Click Download Report as Pdf Format

    Yes you can download as word. configuration available on SQL reporting server.  

  • Seenivasan M Profile Picture
    Seenivasan M 305 on at
    RE: Button Click Download Report as Pdf Format

    Hi Experts,

    Can we download the SSRS report as word document(Like PDF)?

    Regards,

    Seeni

  • ARIFNIIT Profile Picture
    ARIFNIIT 1,391 on at
    RE: Button Click Download Report as Pdf Format

    Are you using 9.0 or higher? so you can use QuirksReportViewer to open Reports.

  • Suggested answer
    Iswarya Profile Picture
    Iswarya 1,345 on at
    RE: Button Click Download Report as Pdf Format

    Hi,

    which version r u working?? based on version have to change this path

      var pth = Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/QuirksReportViewer.aspx";  

    let me know your version, then i will provide correct path

  • Suggested answer
    ARIFNIIT Profile Picture
    ARIFNIIT 1,391 on at
    RE: Button Click Download Report as Pdf Format

    Just open specific report on button click. user can download report as PDF by clicking on inbuilt pdf button.

    open  report  using Script

    function OpenReport(){

    var url = Xrm.Page.context.getClientUrl() + "/crmreports/viewer/viewer.aspx?action=run&helpID=" + rdlName + "&id={" + reportGuid + "}"

    window.open(url, null, 800, 600, true, false, null);

    }

    click on button PDF file.

    2017_2D00_09_2D00_07-12_5F00_54_5F00_21_2D00_Report-Viewer_5F00_-Sales-History.png

  • Verified answer
    Iswarya Profile Picture
    Iswarya 1,345 on at
    RE: Button Click Download Report as Pdf Format

    Hi,

    this is my code

    var reportName;

    var reportGuid;

    function EmailReport() {

       try {

           debugger

           var selectedid = null;

           var reportid = null;

           var req = new XMLHttpRequest();

           var reportName = "Quote Report";

           var context = Xrm.Page.context;

           var serverUrl = context.getClientUrl();

           var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";

           var retrieveResult = new XMLHttpRequest();

           retrieveResult.open("GET", ODataPath + "/ReportSet?$select=Name,ReportId&$filter=Name eq'" + reportName + "'", false);

           retrieveResult.setRequestHeader("Accept", "application/json");

           retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8?");

           retrieveResult.send();

           if (retrieveResult.readyState == 4 /* complete */) {

               if (retrieveResult.status == 200) {

                   var retrieved = this.parent.JSON.parse(retrieveResult.responseText).d;

                   var Result = retrieved.results;

                   if (typeof Result !== "undefined") {

                       reportid = Result[0].ReportId;

                       var params = getReportingSession(reportName, reportid);

                           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");

                       } else {

                           Xrm.Utility.alertDialog(this.statusText);

                       }

                   }

               }

       } catch (ex) {

           throw ex;

       }

    }

    function getReportingSession(reportName, reportGuid) {

       debugger;

       reportName = "Quote Report";

       //reportGuid = "5462c1b7-c0ac-e711-8130-5065f38c1521";

       var selectedIds = Xrm.Page.data.entity.getId();

       selectedIds = selectedIds.replace('{', '');

       selectedIds = selectedIds.replace('}', '');

       var pth = Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/QuirksReportViewer.aspx";  

       var retrieveEntityReq = new XMLHttpRequest();

       var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition attribute='quoteid' 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_quote=" + strParameterXML);

       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;

    }

  • Suggested answer
    Iswarya Profile Picture
    Iswarya 1,345 on at
    RE: Button Click Download Report as Pdf Format

    Hi,

    yes, see this

    community.dynamics.com/.../253073

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Button Click Download Report as Pdf Format

    Hi Iswarya,

    I too got the same requirement, did you got any solution?

    Regards,

    sreekanth

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans