Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Business Central forum

Getting error When Using Stream functions in AL Code.

(0) ShareShare
ReportReport
Posted on by 245

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.

  • Manikanta_501 Profile Picture
    245 on at
    RE: Getting error When Using Stream functions in AL Code.

    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"

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Getting error When Using Stream functions in AL Code.

    Example:

    var

           FileInstream: InStream;

           FileName: Text;

       begin

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

           begin

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

  • Manikanta_501 Profile Picture
    245 on at
    RE: Getting error When Using Stream functions in AL Code.

    Can you give me an example for better understanding.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Getting error When Using Stream functions in AL Code.

    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.

  • Manikanta_501 Profile Picture
    245 on at
    RE: Getting error When Using Stream functions in AL Code.
     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
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Getting error When Using Stream functions in AL Code.

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

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

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 forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans