Task allocation using expressions

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Performers >

Task allocation using expressions

Expressions in allocation rules are usually needed when you need to evaluate complex conditions and select some user that comply conditions given in said expression.

To use expressions select the User property User id  and the Expression option.

The expression created should return an array of ids, of the users that comply with the condition needed. Those users ids will be allocated.

 

Example

In an On boarding process a requester enters the information of a new position including job description, salary, etc.

The next activities that include setting requirements and gathering documents can be performed by any user whose Boss is the process requester.

Thus we need to use an expression to find all users who share the requester as a Boss.

 

Assume in the first activity you save the Requester id in an attribute: <Onboarding.Requester>

 

1. In the Performers definition, fifth step of the Process Wizard, click the activity to define.

 

2. Select User Id as the property for the allocation and select Expression as condition. Click Select Expression

 

Task Allocation18

 

3. Tick the option Based on the result of an expression.

 

Task Allocation 40

 

4. Select the New option.

 

Task Allocation 41

 

5. Create the following expression

 

Task Allocation 42

 

 

 

// Create an array

var Users = new ArrayList();

// Save in a variable the requester

var Requester = <Onboarding.Requester.Id>;

// Get all users whose boss is the requester

var SearchUsers = CEntityManager.GetEntity("WFUser").GetEntityList("","","idBossUser = "+ Requester,"");

// Count how many users comply

var HowManyUsers = SearchUsers.Length;

if(HowManyUsers > 0)

{

// Add each user to the array

 for (var i=0; i < HowManyUsers; i++)

 {        

         var idUser = SearchUsers[i].SurrogateKeyValue;

         Users.Add(idUser);

 }

}

Users;

 

6. Give the expression a name.

It should look like this.

 

Task Allocation 39