Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Business Central forum

Create OutStream

(0) ShareShare
ReportReport
Posted on by 525

Hi
I'm working on a task where I need to get the outstream from XMLPort and pass it to the calling function. I wrote this code

VendFile.CreateOutStream(Ostream);  //file is just intended for creating outstream
ExportVendorsXML.SETDESTINATION(Ostream);

however, I'm unable to do so. On first line it says that 'The type or method can not be used for extension development'.
Is there any other way of creating outstream? 

Thanks in advance :)

Categories:
  • Armela Kamenica Profile Picture
    231 on at
    RE: Create OutStream

    Stefano

    I used your example and tailored it to my needs.

    Using BC 365 and AL code.

    I have the following

    TempBlob.Blob.CREATEOUTSTREAM(outvar);
    xmlport.Export(50101,outvar);
    TempBlob.Blob.CREATEINSTREAM(ReportInStream);
    mypath := 'Send_PO.csv';

    DOWNLOADFROMSTREAM(reportinstream, '', '\\Navision\cust\XXX\CSV\outbox\', '', mypath);
    This creates the file, but it does not put in the folder where I need it.
    It shows up in my download folder with a name of
    Send_PO.csv 
    Any ideas  how to get this file to actually go to the folder on the server.
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Create OutStream

    No this method is native from the AL language so you can use as per your needs in every object.

  • Mohsin Abbas Profile Picture
    525 on at
    RE: Create OutStream

    Is this method limited to work with using reports only?What if we need to write data to file in XML format?

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Create OutStream

    Import and export a file in AL Extension can be handled with DOWNLOADFROMSTREAM and UPLOADINTOSTREAM functions.

    The below code is a sample on how to export a blob data to a file:

    PurchaseHeader.SETFILTER("No.","No.");
    TempBlob.Blob.CREATEOUTSTREAM(OStream);
    REPORT.SAVEAS(1322,PurchaseHeader.GETFILTERS,REPORTFORMAT::Pdf,OStream);
    TempBlob.Blob.CREATEINSTREAM(ReportInStream);
    MyPath := 'test.pdf';
    DOWNLOADFROMSTREAM(ReportInStream,'','', '',MyPath);

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

Featured topics

Product updates

Dynamics 365 release plans