Upload a file using an expression

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Documents and files > File management with expressions >

Upload a file using an expression

In Bizagi, you may upload any file to a File-type attribute without an end user's intervention using an expression uploading the content of the file (as an Array of type sbyte).

 

For example, in a Loans Request Process the Process Entity is called Request. Assume in this entity there is a File-type attribute called HistoryFile that will store a letter uploaded via Web service.

 

AdvanceFilesManagement1

 

The Web Service returns a Bytes Array that contains the data of the file. Assume this array is saved in the variable FileData.

 

To upload a file using an Expression you must type the following code:

 

 

var FileToUpload = Me.addRelation("Request.HistoryFile");

 

FileToUpload.setXPath("FileName", "DisplayNameOfTheFile.txt");

 

FileToUpload.setXPath("Data", FileData);

 

FileName and Data (shown in red) should NOT change. They are part of the code.

 

Note these parameters are components of a file-type attribute. The File Name is the display name of the file. The Data contains the information of the file.

 

AdvanceFilesManagement3

 

Note this expression is similar to the ones used to add records to a collection. This is because file-type attributes are treated as a collection of files, for this reason you can upload many files in a single attribute.

 

The uploaded file will look like this:

 

AdvanceFilesManagement2


Last Updated 1/13/2022 4:02:45 PM