Categories
Bizagi Tips and Tricks

How to get the physical path of uploaded documents

Bizagi code (my version)

The below code helps you trace the location of any uploaded document in Bizagi:

var uploadPath = CHelper.getParameterValue("uploadPath");
var IdEntity = CEntityManager.GetEntity("entity-name").Id;
var IdAttribute = CEntityManager.GetEntity("entity-name").Attributes["attribute-document-name"].Id;
var SurrogateKey = <entity-name.Id>;
var WholePart = (SurrogateKey - (SurrogateKey % 1000)) / 1000;
var bizagiFilePath = uploadPath + "\\" + IdEntity+"\\"+ WholePart +"\\"+ SurrogateKey +"\\"+ IdAttribute;

The explanation of the code

Let’s assume we have a master entity called mIndividual with an attribute of type file called uDocument.

<mIndividual.uDocument>

uploadPath – is the location where the documents are uploaded. Using the CHelper function called getParameterValue, we can access Bizagi’s Environment parameters. This applies to Popular, Advance or Custom.

physical path

IdEntity – is the id of the entity mIndividual. GetEntity().Id returns the same id as if you would do a select on the database, on Entity table where the name of the entity is mIndividual.

IdAttribute – is the id of the attribute uDocument. The same thing happens here. GetEntity().Attributes[].Id returns the same id as if you would do a select on Attribute table where the attribute name is uDocument.

SurrogateKey – is the id of the record from mIndividual table associate with the case current case.

bizagiFilePath – is the physical path where Bizagi stores the file.

Variables example

For Resume.docx the location could be something similar to C:\BizAgi\Projects\Project01\Docs\10063\0\208\10020\Resume.docx

uploadPath = C:\BizAgi\Projects\Project01\Docs\

IdEntity = 10063

WholePart = 0

SurrogateKey = 208

IdAttribute = 10020

Bizagi’s documentation

For more insights into the file uploads please read the article posted on Bizagi’s website: Obtain the physical path of Bizagi uploads.

If you would like to find out more about Bizagi please send us an email.