Tuesday, April 12, 2022

Work with File Object in MS Business central SaaS

Hi All, 

File sharing is an integral part of Data sharing. You can import data from or export data to any external file through file variables.

The Business Central server (SaaS) can't access the user's local file system. To be able to work with files, you need to use streams.

Only the UploadIntoStream and DownloadFromStream functions are available for you to use as a developer in the SaaS version of Business Central. 

UploadIntoStream

Syntax: [Ok :=] UPLOADINTOSTREAM(DialogTitle, FromFolder, FromFilter, FromFile, NVInStream)

Example: 



DownloadFromStream

Syntax: [Ok := ]  File.DownloadFromStream(InStream: InStream, DialogTitle: Text, ToFolder: Text, ToFilter: Text, var ToFile: Text)

Example:


Reach out to me if you have any questions or suggestions. 

Check out other blogs, if you haven't already. 

Kindly suggest what else you want me to blog about. Keep following and supporting!

You can also email me at jyotsnaoberainav@gmail.com

Also, visit my website JONAV if you are looking for NAV/D365BC Training and/or Services!

Thank you! 

Sources: https://docs.microsoft.com/, https://simplanova.com/


2 comments:

  1. Can we save the file to some cloud space or shared drive via job queue.. i mean without any user intervention..

    ReplyDelete
    Replies
    1. Thank you for your question.
      You can have different cloud integration systems with BC SaaS, that is the beauty of it. BC also has the ability to Integrate Sharepoint and OneDrive, you can store your files there.
      On the other hand, you can of course create a job queue which will use that service and export your files there.
      What is shown here, is files that are stored at BC level, all it stores is a metadata, if say a PO is archived, you cannot retrieve that file.
      Hope this helps.

      Delete