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

Bundle reports into a zip file

(0) ShareShare
ReportReport
Posted on by 75

Hi there!

I am working on an extension for our client. And here is what we try to achieve:  Loop the shipment lines to get the source no, run a report for each source no, and save all the reports in a zip file. 

I came up with the following code. It can download an empty zip file that doesn't have any report in it. I am wondering which part was wrong. Please advise,

Thanks a lot!

local procedure BundleReports(ShipmentHeader: Record "Warehouse Shipment Header")
var
ReportParameter: Text;
ShipmentLines: Record "Warehouse Shipment Line";
FileManagement: Codeunit "File Management";
DataCompression: Codeunit "Data Compression";
FileName: Text;
BaseName: Text;
ZipFileName: Text;
GetTotalNumberOfFiles: Integer;
ZipOutStream: OutStream;
ZipInStream: InStream;
blobStorage: Codeunit "Temp Blob";


begin

DataCompression.CreateZipArchive();

blobStorage.CreateOutStream(ZipOutStream);


ZipFileName := ShipmentHeader."No." + '.zip';

ShipmentLines.Reset();
ShipmentLines.SetRange("No.", ShipmentHeader."No.");
ShipmentLines.SetCurrentKey("Source No.");
if ShipmentLines.FindSet() then begin
repeat

FileName := ShipmentLines."Source No.";
Report.SaveAs(50106, ShipmentLines."Source No.", ReportFormat::Pdf, ZipOutStream);

until ShipmentLines.Next() = 0;
end;
DataCompression.SaveZipArchive(ZipOutStream);
DataCompression.CloseZipArchive();
blobStorage.CreateInStream(ZipInStream);
DownloadFromStream(ZipInStream, '', '', '', ZipFileName);
end;

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

    Working solution can be seen here: https://youtu.be/I44oxIoEspM

    Link on the video to Erik’s GitHub so you can download his code and adapt accordingly

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 April 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,216 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,471 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,369

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans