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
    150 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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,965 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,125 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 961 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans