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 365 | Integration, Dataverse...
Suggested Answer

What to do in command of custom ribbon button to download a PDF on click?

(0) ShareShare
ReportReport
Posted on by 52

I'm trying to learn how to create a ribbon button that will allow a user to download a PDF I have uploaded as a web resource.

  1. Using the Ribbon Workbench I have created the button with a command that has no actions tied to it yet.
  2. I've also uploaded a PDF by doing a workaround and changing it's extension to HTML, however leaving the name with a .PDF extension.

I'm a bit unsure if now I need to create a JS web resource that makes a call to that web resource or can I create a simple command so that the user will have the PDF downloaded on their side after a click of the button.

I can't find any examples of this online, any help would be appreciated, thanks!

I have the same question (0)
  • Suggested answer
    ba365guy Profile Picture
    2,950 on at

    1.Create a javascript webresource named "openhtmlpage.js"

    2. Insert following code in the js file

    function openPage()
    {
    Xrm.Utility.openWebResource("new_page1.htm"); //new_page1.htm is your html
    {

    3. I your button command, add an action (type: javascript action)

    4. Choose the javascript file and mention the function name

    5. map the command with button

    6. Save and publish

    7. Test

    Let me know if it works for you

  • Summers Profile Picture
    52 on at

    Thanks for such a speedy reply!! So it works but I don't what to do because now it opens it up as a HTML file since I changed the extension of the PDF to HTML, so that I could upload it as web resource. Do you know how I can get around this? Thanks!

  • ba365guy Profile Picture
    2,950 on at

    Hi Summers

    If it worked, Please close the thread by marking answer as verified.

  • Summers Profile Picture
    52 on at

    Hi there so it's not opening nor downloading the PDF as per what I'm trying to do, it's just trying to open the web resource.

  • Suggested answer
    ba365guy Profile Picture
    2,950 on at

    When naming this html Web Resource, you should still name the file with the normal .pdf extension

    sample web resource name: new_filename.pdf

    The file you upload might be html extension

    For javascript, user

    Xrm.Utility.openWebResource("new_filename.pdf");

  • Summers Profile Picture
    52 on at

    So I made a copy of the pdf file and added a .html extension, then uploaded that file as a web resource giving it the name Help.pdf, and making it type of Webpage (HTML), however it doesn't open up as a PDF in the way it originally use to before I renamed it.

  • ba365guy Profile Picture
    2,950 on at

    What is the use case here?

    If it is a static document you can store the file in common SharePoint folder and open on click of button(you can load sharepoint URL)

    Is it compulsory that file needs to stay in web resource?

  • Summers Profile Picture
    52 on at

    There is no SharePoint site we have that is common for everyone, so I would like to host it on Dynamics, the only way I know so far of how to upload files is by using the Web Resources.

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hello, 

    Please read this blog. You can find how to store your pdf file as a Web ressource

    us.hitachi-solutions.com/.../

  • Suggested answer
    ba365guy Profile Picture
    2,950 on at

    This file approach will not workout or will be too complex with file extensions.

    I can suggest you some work arounds as follows:

    1. Common Cloud Folder (SharePoint / OneDrive - create shared folder / Google Drive - shared folder) - Use the link to open via button click

    1. User word template (embed your pdf document in word template and upload empty word template to D365. You can always download this from D365.

    2. Send an email with your PDF file as attachment to the current user of system.

    You can create an email template. Upload the attachment in the email template. On click of button update a boolean field on the form (Yes/no). On update of boolean field send an email to current user using the email template.

    These are just a work arounds.

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 60 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 51

#3
Satyam Prakash Profile Picture

Satyam Prakash 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans