Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Download the document attachment in D365

(0) ShareShare
ReportReport
Posted on by 4

Hi All,

In D365 Cloud implementation, End user will attach multiple documents against one particular Source document. We need to download all the attachments in single click. 

I have tried to below code to download all the attachment while clicking download button. Code's are shown below.

By passing source document record and fetching all the attached documents and loops are working fine. Code is working as same like 'Open' button in the attachment form. But, it is download only the latest file (as per no. of attachments against the document)..

pastedimage1607867379876v2.png

pastedimage1607867154945v1.png

Please suggest.

Thanks

  • Suggested answer
    Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: Download the document attachment in D365

    Here is a little proof of concept (using text files, not actual attachments). Check out whether it meets your requirements.

    class DownloadDemo
    {
        public static void main(Args _args)
        {
            DownloadDemo::SendStringAsFileToUser('a', 'a.txt');
            DownloadDemo::SendStringAsFileToUser('b', 'b.txt');
        }
    
        private static void SendStringAsFileToUser(str _content, str _fileName)
        {
            System.Byte[] byteArray = System.Text.Encoding::UTF8.GetBytes(_content);
            System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
            str downloadUrl = File::SendFileToTempStore(stream, _fileName);
            new Browser().navigate(downloadUrl, true, false);
        }
    }

  • Muthusamy Profile Picture
    4 on at
    RE: Download the document attachment in D365

    Thanks Martin for your reply. Right now, I am trying to download the file one by one. Otherwise, download an archive (single file as 'rar' or 'zip') containing all the attachments is also ok for me.

    Thanks,

  • Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: Download the document attachment in D365

    Is your goal downloading files one by one or downloading an archive (= a single file) containing all the attachments?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans