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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to create downloaded file name dynamically in SSRS reports

(0) ShareShare
ReportReport
Posted on by

Dear All,

i have Implemented the SSRS report using Fetch XML for the contact Entity.

Now i want to achieve this:

Suppose One of the Contact Record i have opened Whose ContactName is Contact-001 and when i click on the Run Report from the particular record form ( Contact-001) that SSRS report will run, Now when i export that report to the PDF format the PDF name will come as RDL Name instead of that i want to print Contact-001 as that PDF Name.

Please Suggest me on the same.

Regards,

Krishna.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    var reportName;
    var reportGuid;

    //you have to pass your "Autonumber here"(Contact-001->this attribute here)
    var fileName = "PDF01";
    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;

    }




  • Community Member Profile Picture
    on at

    Hi Iswarya,

    Thanks for the suggestion.

    i will try and let you know the same.

    Regards,

    Krishna.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans