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)

Download Attachments via Code

(0) ShareShare
ReportReport
Posted on by 70

Hi All,

We have a custom entity called Documents which is used to store attachments of various formats (PDF, Word, txt, etc.). There is a custom iFrame on our Dashboard which displays grid of these document records. Now we need to allow the user to download the document attachments directly from this grid without opening the individual Document record and then click on the attachment file. The custom iFrame grid will have a Download button, clicking on which should download the attachment directly in browser.       

My initial thought was that this implementation would be similar to how we open any form, view, dialog or report in CRM (by generating a dynamics URL) but it doesn't look that easy for attachments. Kindly provide your inputs on this.

Note:

1. I found this article on MSDN which discusses downloading attachment via plugin code. One option I can think of is to have similar logic written in a custom Action via code and call this Action when the Download button is clicked. 

*This post is locked for comments

I have the same question (0)
  • ashlega Profile Picture
    34,477 on at

    Hi,

     you might try this:

    community.dynamics.com/.../downloading-dynamics-crm-attachments-with-javascript

     I'm not sure if it's fully "supported" because attachments have never been fully supported on the scripting side in Dynamics, so use at your own risk

    EDIT: Just realized there is a missing download.js library there, so I'm not sure you can use it as is

  • ashishtrivedi Profile Picture
    70 on at

    Hey Alex.. I am not sure whether this solution would work for all kind of attachment formats and all devices.

    Any inputs on the Action approach?

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Please refer the community thread below.

    community.dynamics.com/.../179264

    Hope this helps.

  • Community Member Profile Picture
    on at

    There are some resource available. You can refer to this to see if it helps.

    mahadeomatre.blogspot.com.au/.../view-or-download-attachments-for.html

  • Verified answer
    ashishtrivedi Profile Picture
    70 on at

    Thanks all for your inputs. For any future references coming to this thread, I took the approach of querying the 'annotation' entity from Javascript using WebAPI. This WebAPI query will fetch the 'documentbody' and 'mimetype' attributes of the 'annotation' entity record which can then be parsed in Javascript to render it on client browser as the actual document (PDF, Word, etc). This solution works well for both browser and iPad versions of CRM.  

    Note that although I implemented this functionality on Javascript side, it can be achieved on the similar lines from C# code by querying the 'annotation' entity and parsing the results.

  • Community Member Profile Picture
    on at

    Hi Ashish,

    I have a similar requirement. I have to show the notes attachment(pdf, excel, word) in an iframe on the form.

    Could you guide how we can display the pdf or excel in iframe and if it is possible?

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