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)

Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/QuirksReportViewer.aspx" returns 404 in version 9

(0) ShareShare
ReportReport
Posted on by

I hope someone can figure this out. 

The following snippet of code is widely used (see link) when attempting to run an online report and capture it's output, so that is it can be attached to an email.

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

In version 9 of Dynamics 365), the URL returns a 404 error. 

It still seems to work in version 8.2.1 of D365.

Any suggestions would be appreciated.

Cheers,

Mark

*This post is locked for comments

I have the same question (0)
  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Your url is incorrect:

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

    Says "Quirks" Report viewer. Are you looking for QuickReportViewer by any chance, or maybe just viewer.aspx?

    Hope this helps.

  • Community Member Profile Picture
    on at

    Sorry. Using Fiddler, and Dynamics 365, version 8.2.1, it should definitely be

    https://{uniquename}.crm.dynamics.com/CRMReports/rsviewer/QuirksReportViewer.aspx

    It looks like, but am not convinced yet, that it got replaced by

    Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/reportviewer.aspx";

    I'm still struggling to match the POST parameters, though.

  • Verified answer
    Community Member Profile Picture
    on at

    In version 9.0, I was successful by replacing QuirksReportViewer.aspx with reportviewer.aspx.

  • AnkitSinghal Profile Picture
    256 on at

    0081.error.png

    Hi,

    I am facing above error when i opened pdf.

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi Ankit,

    refer this link

    community.dynamics.com/.../205829

    follow Bharat instructions, as follows(i too face same issue,after follow his instruction i got resolved)

    The problem may be with the way you have developed the report in Visual Studio

    Try creating a very simple Invoice Report with only a few fields, maybe something like this as your DataSource, note the use of enableprefiltering:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

    <entity name="invoice" enableprefiltering="1">

    <attribute name="invoicenumber" />

    <attribute name="name" />

    <attribute name="totalamount" />

    <attribute name="customerid" />

    <attribute name="statuscode" />

    <attribute name="invoiceid" />

    <attribute name="createdon" />

    <attribute name="description" />

    <order attribute="name" descending="false" />

    </entity>

    </fetch>

    In your parameters section create a parameter called CRM_invoice.  Data Type should be Text

    Add a fieds to the report and upload into CRM, change the report name and guid parameters to match this new report.  Then try running the code.

    I had a lot of problems initially thinking it was report session errors but it was actually the report itself that wasnt correct

  • AnkitSinghal Profile Picture
    256 on at

    Hi Iswarya Rengarajan,

    I used same code but i am not able to open PDF.

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    for testing purpose, first you create simple new report ,pass this new report name and id. after u test pdf download or not.

    see this link

    https://community.dynamics.com/crm/f/117/p/253073/711593#711593

  • AnkitSinghal Profile Picture
    256 on at

    Hi,

    This is my code:

    function runReportToPrint() {

    var reportName = "Invo.rdl";  //Name of your invoice report

    var reportGuid = "9657861E-50B9-E711-A94E-000D3AF28673"; //GUID of your invoice report

    var invoicenumber = Xrm.Page.getAttribute("invoicenumber").getValue()

    if (invoicenumber != null) {

    invoicenumber = invoicenumber.substring(4, 9);

    var params = getReportingSession();

    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=" + invoicenumber + "&ContentDisposition=OnlyHtmlInline&Format=PDF";

    window.open(newPth, "_self");

    encodePdf(params);

    }

    else {

    alert("Invoice ID is Missing");

    }

    }

    function getReportingSession(reportName, reportGuid) {

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

    recordId = recordId.replace('{', '').replace('}', '');

    var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='invoice'><all-attributes /><filter type='and'><condition attribute='invoiceid' operator='eq' value='" + recordId + "' /> </filter></entity></fetch>";

    var pth = Xrm.Page.context.getClientUrl() + "/CRMReports/rsviewer/reportviewer.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" + reportGuid + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName=" + reportName + "&isScheduledReport=false&p:CRM_invoice=" + 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);

    alert(ret[0]);

    return ret;

    }

    function encodePdf(responseSession) {

    var retrieveEntityReq = new XMLHttpRequest();

    var pth = Xrm.Page.context.getClientUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + responseSession[0] + "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + responseSession[1] + "&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";

    retrieveEntityReq.open("GET", pth, true);

    retrieveEntityReq.setRequestHeader("Accept", "*/*");

    retrieveEntityReq.responseType = "arraybuffer";

    retrieveEntityReq.onreadystatechange = function () {

    if (retrieveEntityReq.readyState == 4 && retrieveEntityReq.status == 200) {

    var binary = "";

    var bytes = new Uint8Array(this.response);

    for (var i = 0; i < bytes.byteLength; i++) {

    binary += String.fromCharCode(bytes[i]);

    }

    var bdy = btoa(binary);

    createNote(bdy);

    alert(bdy);

    }

    };

    retrieveEntityReq.send();

    }

    function createNote(data) {

    alert("createNote");

    var note = {};

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

    recordId = recordId.replace('{', '').replace('}', '');

    var invoicenumber = Xrm.Page.getAttribute("invoicenumber").getValue()

    invoicenumber = invoicenumber.substring(4, 9);

    var refInvoice = new Object();

    refInvoice.LogicalName = "invoice";

    refInvoice.Id = recordId;

    note.ObjectId = refInvoice;

    note.ObjectTypeCode = refInvoice.LogicalName;

    note.Subject = "Invoice: " + invoicenumber;

    note.MimeType = "application/pdf";

    note.DocumentBody = data;

    note.FileName = invoicenumber + ".pdf";

    XrmServiceToolkit.Rest.Create(

    note,

    "AnnotationSet",

    function (result) {

    //Alert user

    alert("Note Created");

    //Refresh data so user sees newly created note

    Xrm.Page.data.refresh(false);

    },

    function (error) {

    alert(error.message);

    },

    true

    );

    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////

    //////////////////////////////////////////////////////////////////////////////////////////////////

    And This is my fetch XML:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

    <entity name="invoice" enableprefiltering="1">

    <attribute name="invoicenumber" />

    <attribute name="name" />

    <attribute name="totalamount" />

    <attribute name="customerid" />

    <attribute name="statuscode" />

    <attribute name="invoiceid" />

    <attribute name="createdon" />

    <attribute name="description" />

    <order attribute="name" descending="false" />

    </entity>

    </fetch>

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    what version are u working on?

    when debugging check this line

    var x = retrieveEntityReq.responseText.lastIndexOf("ReportSession=");

    var y = retrieveEntityReq.responseText.lastIndexOf("ControlID=");

    responseText->did u get any error

  • AnkitSinghal Profile Picture
    256 on at

    I am working on Dynamics 365 (ver 9). its gives " Not Found".

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