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.



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




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




4. Select the New option.




5. Create the following expression




// Create an array

var Users = new ArrayList();

// Create the filter for the requester

var parameters = new FilterParameters();

parameters.AddParameter("@Requester", <Onboarding.Requester.Id>);

// Get all users whose boss is the requester
var SearchUsers = Me.getXPath("entity-list('WFUser', 'idBossUser=@Requester')",parameters);

// Count how many users comply

var HowManyUsers = SearchUsers.size();

if(HowManyUsers > 0)


// Add each user to the array

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


         var idUser = SearchUsers[i].getXPath("Id");






6. Give the expression a name.

It should look like this.