Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Unanswered

Send body from OneDrive PDF file to JavaScript Resource and then download it

Posted on by 15

Here is the thing,

I have a WebResource connected to a Ribbon Button that calls a flow. 

The Flow gets a Word Template from my OneDrive, converts it to PDF(Preview) and sends it back to the Javascript Web Resource using HTTP Response.

The document is then downloaded, but when I open it, it says "We can't open this file".

Here is the Flow Response:

And here is the code that is used to fetch the response and download it:

function downloadFile(blob, fileName) {
        debugger;
        if (navigator.msSaveBlob) { // IE 10 
            navigator.msSaveBlob(blob, fileName);
        } else {
            var link = document.createElement("a");
            if (link.download !== undefined) {
                var url = URL.createObjectURL(blob);
                link.setAttribute("href", url);
                link.setAttribute("download", fileName);
                link.style.visibility = 'hidden';
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
            }
        }
    }

The entire code is pretty much a copy paste of this with a few changes:

https://www.itaintboring.com/powerapps/how-to-add-a-ribbon-button-that-calls-a-power-automate-flow/

I suspect it is something to do with the Content-Type, or the fact that the file is Converted(Preview) and not Saved to OneDrive.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans