Hi,
how do i create file in extension, without changing target in app.json (because Extension cannot use FILE datatype) ? In some thread i have read that i need to use Outstream and InStream, but any example using outstream to create text file?
in issue #934 is an example of picture.
Thanks
This is an example that create a text file with 3 lines.
codeunit 50102 CreateFiles
{
trigger OnRun()
begin
end;
procedure CreateTxtFile(FileName: Text)
var
InStr: InStream;
OutStr: OutStream;
tmpBlob: Record TempBlob temporary;
CR: char;
LF: char;
begin
CR := 13;
LF := 10;
tmpBlob.Blob.CreateOutStream(OutStr);
OutStr.WriteText('First line'+ CR + LF);
OutStr.WriteText('Second line'+ CR + LF);
OutStr.WriteText('Third line'+ CR + LF);
tmpBlob.Blob.CreateInStream(InStr);
DownloadFromStream(InStr, '', '', '', FileName);
end;
}
thanks @ftornero9 , your code works well.
first i'm curious what for CR and LF, but looks like it is necessary for line breaking.
https://dynamicsuser.net/nav/f/developers/8258/carriage-return-crlf-into-a-text-variable
anyone asked before how to silently download file to specific folder using code @ftornero9 given?
in https://forum.mibuso.com/discussion/69837/downloadfromstream-function-question
we can use method BLOBExportToServerFile from codeunit 419, but in extension we couldn't use the method.
is there any other way?
@hydhart not at the moment.
Most helpful comment
This is an example that create a text file with 3 lines.
codeunit 50102 CreateFiles
{
trigger OnRun()
begin
}