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 :
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
    237,880 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
    237,880 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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans