SBX - Search With Button

SBX - Forum Post Title

Getting error When Using Stream functions in AL Code.

Dynamics 365 Business Central Forum

Manikanta Adabala asked a question on 12 Jun 2019 1:03 AM

Question Status

Suggested Answer

Hello All.,

When I am Using Stream( Write() , Open() , etc.. ) functions in AL Language for Business Central of Cloud Version(SaaS) Getting error . Can any one suggest me what I have to do , to use these functions in my Code or Is there any alternative.

Error The type or method 'Write' cannot be used for 'Extension' development.

Reply
Suggested Answer

You need to use InStream and OutStream data types on SaaS:

docs.microsoft.com/.../instream-and-outstream-data-types

Reply
Manikanta Adabala responded on 12 Jun 2019 2:23 AM
 I Defined Variables Like below in a Function 
var
MyFile: File;
DestinationFile: File;
StreamInTest: InStream;
OutStreamTest: OutStream;
Buffer: Text[250];
SkipLF: Boolean;
PackingCenterL: Record 14027060;
And Write Code Like below.
begin
NewFilePath := INSSTR(FilePathP,'_',STRLEN(FilePathP)-3);
MyFile.OPEN(FilePathP);
MyFile.CREATEINSTREAM(StreamInTest);
IF EXISTS(NewFilePath) THEN
ERASE(NewFilePath);
DestinationFile.CREATE(NewFilePath);
DestinationFile.CREATEOUTSTREAM(OutStreamTest);
 
Even though I am Getting same error.
 
Error : The type or method 'Open' cannot be used for 'Extension' development
Reply
Suggested Answer

File.OPEN is not supported on SaaS, you don't have a file system in the cloud. You need to use UploadIntoStream to load a file to an InStream.

Reply
Manikanta Adabala responded on 12 Jun 2019 2:32 AM

Can you give me an example for better understanding.

Reply
Suggested Answer

Example:

var

       FileInstream: InStream;

       FileName: Text;

   begin

       if UploadIntoStream('', '', '', FileName, FileInstream) then

       begin

          //Here you have your InStream loaded with the file content

Reply
Manikanta Adabala responded on 13 Jun 2019 1:47 AM

I Wrote Code like below in my Codeunit

OutputFile: File;(Variable)

OutputFile.WRITE(STRSUBSTNO('A%1,%2,0,3,1,1,N,"%3"',ColNo, RowNo, PackageLineL."No."));

And Getting error "The type or method 'Write' cannot be used for 'Extension' development"

Reply
Suggested Answer

You need to use InStream and OutStream data types on SaaS:

docs.microsoft.com/.../instream-and-outstream-data-types

Reply
Suggested Answer

File.OPEN is not supported on SaaS, you don't have a file system in the cloud. You need to use UploadIntoStream to load a file to an InStream.

Reply
Suggested Answer

Example:

var

       FileInstream: InStream;

       FileName: Text;

   begin

       if UploadIntoStream('', '', '', FileName, FileInstream) then

       begin

          //Here you have your InStream loaded with the file content

Reply

SBX - Two Col Forum

SBX - Migrated JS