SBX - Search With Button

SBX - Forum Post Title

Create OutStream

Dynamics 365 Business Central Forum

Mohsin Abbas asked a question on 5 Sep 2018 9:57 AM
My Badges

Question Status

Verified

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 :)

Reply
Verified Answer

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

Reply
Mohsin Abbas responded on 12 Sep 2018 7:11 AM
My Badges

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

Reply
Suggested Answer

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

Reply
Armela Kamenica responded on 23 Oct 2018 4:47 PM
My Badges

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.
Reply
Verified Answer

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

Reply
Suggested Answer

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

Reply

SBX - Two Col Forum

SBX - Migrated JS