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 :
Business Central forum

Issue in saving multiple reports while running test tool in Business Central

(0) ShareShare
ReportReport
Posted on by 121
Hello guys,
I have developed code to test the App through test tool, Here I'm trying to develop code to download/Save multiple reports while Microsoft User runs the Test tool, So that user can see that reports are running successfully.
But i have an issue here in the following code. when i ran the test tool it is only saving the
last report i,e RunItemLabel4x6Report and if we comment the last procedures then it is downloading
the first report i,e RunItemLabel2x3Report.
I'm thinking that it is overriding the reports while saving
another issue is-->  it is  saved into downloads folder instead of saving into the path i mentioned below.
Is there any solution for this issue?
Thanks in advance!!!
codeunit 50001 "Testing App"
{
    Subtype = Test;
  
[Test]
    procedure RunItemLabels2x3Report()
    var
        ItemLbl2x3RPT: Report "Item label 2x3 inch";
        ItemL: record Item;
        outstreamL: outstream;
        InstreamL: Instream;
        tempblob: Record TempBlob temporary;
        Param: Text;
        Uploaded: Boolean;
        filename: text;
        Recref: RecordRef;
    begin
        begin
            ItemL.reset;
            ItemL.FindFirst();
            ItemL.setrange("No.", ItemL."No.");
            ItemL.SetFilter("Common Item No.", '<>%1', '');
            ItemL.FindFirst();
            clear(ItemLbl2x3RPT);
            tempblob.init;
            tempblob.blob.CreateOutStream(OutstreamL);
            tempblob.blob.CreateInStream(InstreamL);
            Recref.GetTable(ItemL);
            if ItemLbl2x3RPT.SaveAs(Param, ReportFormat::Pdf, outstreamL, Recref) then
                //message('saved');
                filename := 'Item Label 2x3 Report.pdf';
            DownloadFromStream(InstreamL, 'Report Output', 'C:\Temp2\', 'All Files (*.*)|*.*', filename);
        end;
    end;
[Test]
    procedure RunItemLabels3x3Report()
    var
        ItemLbl3x3RPT: Report "Item Label 3x3 inch";
        ItemL1: record Item;
        outstreamL: outstream;
        InstreamL: Instream;
        tempblob: Record TempBlob temporary;
        Param: Text;
        Uploaded: Boolean;
        filename: text;
        Recref: RecordRef;
    begin
        ItemL1.reset;
        ItemL1.FindFirst();
        ItemL1.setrange("No.", ItemL1."No.");
        ItemL1.SetFilter("Common Item No.", '<>%1', '');
        ItemL1.FindFirst();
        clear(ItemLbl3x3RPT);
        Clear(Recref);
        tempblob.init;
        tempblob.blob.CreateOutStream(OutstreamL);
        tempblob.blob.CreateInStream(InstreamL);
        Recref.GetTable(ItemL1);
        if ItemLbl3x3RPT.SaveAs(Param, ReportFormat::Pdf, outstreamL, Recref) then
            //message('saved');
            filename := 'Item Label 3x3 Report.pdf';
        DownloadFromStream(InstreamL, 'Report Output', 'C:\Temp2\', 'All Files (*.*)|*.*', filename);
    end;
[Test]
    procedure RunItemLabels4x6Report()
    var
        ItemLbl4x6RPT: Report "Item Label 4x6 inch";
        ItemL2: record Item;
        outstreamL: outstream;
        InstreamL: Instream;
        tempblob: Record TempBlob temporary;
        Param: Text;
        Uploaded: Boolean;
        filename: text;
        Recref: RecordRef;
    begin
        ItemL2.reset;
        ItemL2.FindFirst();
        ItemL2.setrange("No.", ItemL2."No.");
        ItemL2.SetFilter("Common Item No.", '<>%1', '');
        ItemL2.FindFirst();
        clear(ItemLbl4x6RPT);
        tempblob.init;
        tempblob.blob.CreateOutStream(OutstreamL);
        tempblob.blob.CreateInStream(InstreamL);
        Recref.GetTable(ItemL2);
        if ItemLbl4x6RPT.SaveAs(Param, ReportFormat::Pdf, outstreamL, Recref) then
            //message('saved');
            filename := 'Item Label 4x6 Report.pdf';
        DownloadFromStream(InstreamL, 'Report Output', 'C:\Temp2\', 'All Files (*.*)|*.*', filename);
    end;

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans