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;
}