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

Download multiple XML files

(1) ShareShare
ReportReport
Posted on by 18
Basically I want to export multiple Posted Sales Credit Memos as separate XML files. 
Example: If I select 5 Credit Memos and click the action, It should download 5 separate XML files.
 
My current code only downloads a single XML file combining all the 5 Credit Memos that I select.
How to make it download separate XML files for each Credit Memo?
 
action("XML Export")
            {
                ApplicationArea = All;
                Image = Export;
                Promoted = true;
                PromotedCategory = Category6;
                PromotedIsBig = true;

                trigger OnAction()
                var
                    SalesCrMemoHeader: Record "Sales Cr.Memo Header";
                    SalesCrMemoHeader2: Record "Sales Cr.Memo Header";
                    XMLexport: XmlPort "Sales Credit Memo XML Export";
                    EDILog: Record "EDI Log";
                    TempBlob: Codeunit "Temp Blob";
                    FileMgmt: Codeunit "File Management";
                    DocType: Enum "Sales Document Type";
                    OutS: OutStream;
                    InS: InStream;
                    FileName: Text[250];
                    XMLDoc: XmlDocument;
                    Description: Text;
                begin
                    CurrPage.SetSelectionFilter(SalesCrMemoHeader);
                    if SalesCrMemoHeader.FindSet() then
                        repeat
                            FileName := SalesCrMemoHeader2."No." + '_XML_Export.xml';
                            TempBlob.CreateOutStream(OutS);
                            XMLexport.SetTableView(SalesCrMemoHeader2);
                            XMLexport.SetDestination(OutS);
                            XMLexport.Export();
                            TempBlob.CreateInStream(InS);

                            if DownloadFromStream(InS, '', '\\C:\XMLFiles\', '', FileName) then
                                EDILog.InsertEDILog(SalesCrMemoHeader2."No.", DocType::"Credit Memo");
                        until SalesCrMemoHeader.Next() = 0;
                end;
            }
 
I have the same question (0)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
    Hi,
     
    I think XML files should be grouped together in a zip file, since browsers don't support multiple downloading of files.
     
    BR
    Mohamed Amine MAHMOUDI
  • Gerardo Rentería García Profile Picture
    25,157 Most Valuable Professional on at
  • Verified answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at
    Hi, hope the following helps as well.
    Dynamics 365 Business Central: FileManagement.BLOBExport only save last file? -> Adding multiple files into a zip file
     
    Thanks.
    ZHU

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans