Upload images via an expression

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Documents and files > File management with expressions >

Upload images via an expression


In Bizagi you may upload images via expressions and associate them with an Image-type attribute without the intervention of end users.


Uploading images with Bizagi's expression editor

To upload an image using an expression, you must type the following code:


Me.setXPath("ImageUpload.image.FileName", "image.png");

var bytes = System.Convert.FromBase64String("[base64 image]");

Me.setXPath("ImageUpload.image.data", bytes);


Take into account the following considerations of the code above:

"ImageUpload" is the name of the Process Entity. You must replace this with the name of your Process entity.

"image" is the name of the attribute where the image is going to be stored in the Process Entity. You must replace this with the name of the attribute where you will store your image.

"FileName" and "data" are properties of the Image-type attributes. this part of the code should not change.





The line #2 of the code converts an image from a base64 string to a byte array, as it is the parameter needed to upload an image.


The following image shows the rule defined. Take into account that some of the parameters are case sensitive, so be careful with the use of uppercase and the lowercase.




For this example the rule was defined to be executed when the user saves the task. In the work portal, when the user goes to the specific task where the rule was defined and saves the work, the image will be automatically uploaded.




Uploading images through external systems

Images can also be uploaded using external systems. To know more about how to upload images through these systems, click here.