Announcements
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)..
Please suggest.
Thanks
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); } }
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,
Is your goal downloading files one by one or downloading an archive (= a single file) containing all the attachments?
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator