Obtain the physical path of Bizagi uploads

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples > File management with expressions >

Obtain the physical path of Bizagi uploads

Overview

This article describes how to calculate the physical path of uploads in Bizagi.

Recall that uploads in Bizagi are those documents or other types of files, which have been attached to a specific case, either via the user interface or by means of Bizagi's API (e.g, SOAP web services, business rules).

Specifically, they consider all files that reside on attributes of the type file or image, in your Bizagi process model.

For more information about file or image attributes refer to Attribute types.

 

When is this useful?

Regularly, you will not need to worry about the exact physical location of uploads in Bizagi.

Bizagi manages uploads consistently across its different components, including its user interfaces, when either saving them or when viewing them afterward.

However, there may be situations in which will want to process (read or update) information contained inside of an uploaded file.

When this is the case, you may locate the file in its physical path and use business rules (i.e, component library features) to manipulate the file and its contents.

 

note_pin

This approach works if you are storing files in a file server (excludes ECM integration when you use a SharePoint, Alfresco, or similar repository).

 

It also applies when that file has been already persisted physically by Bizagi.

This means that when a file is uploaded for the first time, within that same task you may not access it physically because it currently resides within the scope of that task.

The file will be located in such physical path after the transaction has been committed.

For more information about Bizagi scopes, refer to Scopes.

 

 

Physical path formula

The following formula refers to the dynamical sub-folder structure contained inside of the Upload Path parameter of your project, which is configured as described at Advanced Environment Configuration.

The sub-folder structure is organized as described below:

...\IdEntity\WholePart\SurrogateKey\IdAttribute\

 

Recall that by default, the base path as represented by %BA_DEFAULT_UPLOADPATH%, is located at C:\Bizagi\Projects\[Your_Project]\Docs\.

For this formula, consider:

 

IdEntity: It is the Id of the entity, to which the file type attribute belongs to. In order to know the id of the entity, you may need to query the table ENTITY of your project.

This is a static information that will maintain the same since the creation of the entity in Bizagi Studio.

 

SurrogateKey: It is the value of the key of this entity's instance, where the file type attribute is. In order to know the key value of the entity's instance, you may need to obtain the desired entity and checkout its .SurrogateKeyValue.

This is dynamic information, therefore you can know this information in runtime, as each process' case will have a different SurrogateKey.

 

WholePart: It is defined as the whole number of the dividing the SurrogateKeyValue by 1000; or can be obtained with the following calculation:

  WholePart = (SurrogateKey - (SurrogateKey Module 1000)) / 1000

  Again, this is dynamic information as it is derived from the SurrogateKeyValue.

 

IdAttribute: It is the id of the attribute of file type that currently stores the uploaded file. In order to know the id of the attribute, you may need to query the table ATTRIB of your project. This is a static information that will maintain the same since the creation of that attribute through Bizagi Studio options.

 

 

Example

A file was uploaded in an entity called Products (id number 10043 for that ENTITY).

The file type attribute in Products which stores this file is called Document (id number 10010 in ATTRIB, for that attribute).

Therefore, for this example, the physical path is calculated as follows:

 

IdEntity: 10043.

IdAttribute: 10010.

SurrogateKey: 205 (obtained from the created case)

Whole part: 0 (Whole part = (205 - 205) / 1000)

 

Assuming the upload path is configured in Bizagi Studio for this project as: C:\BizAgi\Projects\Project01\Docs\.

Then the whole path to access this file would be: C:\BizAgi\Projects\Project01\Docs\10043\0\205\10010\.

 

If your uploaded file is called OctoberBalances.xls, then your file is available as C:\BizAgi\Projects\Project01\Docs\10043\0\205\10010\OctoberBalances.xls.

 

note_pin

In order to obtain the fileName of your uploaded file dynamically, use the getXPath similarly to the way described at Uploading Files using expressions.