web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

I have the same question (0)
  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at

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

  • Muthusamy Profile Picture
    4 on at

    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,

  • Suggested answer
    Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at

    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);
        }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 521 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 438

#3
Adis Profile Picture

Adis 261 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans