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)

To pass arraybuffer to html web ressource

(0) ShareShare
ReportReport
Posted on by 1,145

Hello Everybody,

First of all I am working on CRM Online 8.2

I'm trying to download a file, using this code:

     var blob = new Blob([file],
{
type: type
});
var URL = window.URL || window.webkitURL;
var downloadUrl = URL.createObjectURL(blob);
if (filename)
{
var a = document.createElement("a");
if (typeof a.download === 'undefined')
{
window.location = downloadUrl;
}
else
{
a.href = downloadUrl;
a.download = filename;
document.body.appendChild(a);
a.click();
}


Assuming that "document.createElement" is not supported, I found another solution, that is using an Html page that holds the download.

The probleme is that I dont know how to pass blob to the html,  I tried:

var customParameters = encodeURIComponent("first="+blob+");

Xrm.Utility.openWebResource('Shared/Download',customParameters,300,300);

Unfortunatly does'nt work.

Have you any idea?

Thank you

Regards,

Saad

*This post is locked for comments

I have the same question (0)
  • gdas Profile Picture
    50,091 Moderator on at

    Hi  ,

    I am not sure about that as this is also not a good idea to pass file content using query string with limited size. As an alternate if you get the file content in your onload of web resource and then append file content using  document.createElement , may be this is one approach you can do.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    You can try the following (though this is browser based):

    if (binaryPDFContent != null && navigator.msSaveBlob)

       navigator.msSaveBlob(new Blob([binaryPDFContent], { type: mimetype }), "MyDoc.docx");

    else

    {

      var blob = new Blob([binaryPDFContent], { type: mimetype });

      var downloadUrl = URL.createObjectURL(blob);

      var a = document.createElement("a");

      document.body.appendChild(a);

      a.style = "display: none";

      a.href = downloadUrl;

      a.download = "MyDoc.docx";

      a.click();

      URL.revokeObjectURL(downloadUrl);

    }

    The else portion, you already had, but try using navigator.msSaveBlob

    Hope this helps.

  • saadzag Profile Picture
    1,145 on at

    Hello,

    The content of files, is in arraybuffer. And I cannot pass arraybuffer using query string.

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