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 :
Small and medium business | Business Central, N...
Suggested Answer

Attachment in Business Cental

(0) ShareShare
ReportReport
Posted on by 5

Is any way in which we can download all the attachment from posted Purchase invoices at once?

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    157 on at

    Standard page action is like this:

    action(Preview)

               {

                   ApplicationArea = All;

                   Caption = 'Preview';

                   Image = Export;

                   Promoted = true;

                   PromotedCategory = Process;

                   PromotedIsBig = true;

                   Scope = Repeater;

                   ToolTip = 'Get a preview of the attachment.';

                   trigger OnAction()

                   begin

                       if "File Name" <> '' then

                           Export(true);

                   end;

               }

    Potentially you could add a new version of this but have setselectionfilter and then loop on the results with the Export() function

    Setselectionfilter details: docs.microsoft.com/.../page-setselectionfilter-method

  • Indira88 Profile Picture
    990 on at

    Hi Josh,

    Not able to figure out how this could be done.I am trying various ways not able to get it right.

    certain files are becoming corrupted after downloading.

  • Suggested answer
    MahGah Profile Picture
    15,597 on at

    Adding to Josh's guideline 

    See the following by yzhums . I know it is a guideline for different purposes but it may give you an idea. 

    https://yzhums.com/20030/

  • Indira88 Profile Picture
    990 on at

    Hi Mahgah,

    I tried with these guidelines only.

    If you see the code is in line with the suggestion.

    ZipFileName := 'Attachments_' + Format(CurrentDateTime) + '.zip';

           DataCompression.CreateZipArchive();

           docAttached.Reset();

           docAttached.SetRange(JobNo, Rec."Job No.");

           docAttached.SetRange(JobTaskNo, Rec."Job Task No.");

           docAttached.SetRange("Table ID", 122);

           docAttached.SetRange("No.", docno);

           if docAttached.FindSet() then begin

               Page.Run(1173, docAttached);

               repeat

                   TempBlob.CreateOutStream(DocumentStream);

                   RecRef.GetTable(docAttached);

                   FldRef := RecRef.Field(docAttached.FieldNo("No."));

                   FldRef.SetRange(docAttached."No.",);

                   if RecRef.FindSet() then begin

                       repeat

                           TempBlob.CreateInStream(IStream);

                           docAttached."Document Reference ID".ExportStream(DocumentStream);

                           FullFileName := Format(docAttached."File Name" + '.' + docAttached."File Extension");

                           DataCompression.AddEntry(IStream, FullFileName);

                       until RecRef.Next() = 0;

                   end;

               until docAttached.Next() = 0;

               Tempblob.CreateOutStream(DocumentStream);

               DataCompression.SaveZipArchive(DocumentStream);

               TempBlob.CreateInStream(IStream);

               DownloadFromStream(IStream, '', '', '', ZipFileName);

           end;

    This is the code.

    Thanks,

    Indira

  • Suggested answer
    MahGah Profile Picture
    15,597 on at

    Sorry Indira. This is out of area of my knowledge but does the following by TeddyH  help?

    thatnavguy.wordpress.com/.../

  • Indira88 Profile Picture
    990 on at

    Hi All,

    Got a solution to this.

    the variable Temblob was not getting cleared in th begining of the loop and hence the issue was occuring.It works fine now.

    Thank you for all the help

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,021 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,083 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 731 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans