Iterating using expressions
Overview
In scripting expressions, you can iterate elements such as collections or parameter entities using different functions. This article explains the syntax that you have to use to iterate different elements in Bizagi. All functions that you can use to iterate elements in Bizagi can return three types of objects: BizagiArrayList, ArraysList, and Array. This section describes the syntax to iterate each type.
Bizagi Array Lists
A Bizagi Array List is a type of object similar to a collection, that contains all the information of the iterated object. The following functions return Bizagi Array Lists:
- GetValuesAsCollection
- Me.getXPath("entity-list('','')", parameters)
- Me.getXPath("CollectionXpath")
- (CollectionXpath)
If you declare a variable as an object type you can obtain the i-th row of the array list and the value of a particular column of that row as follows:
- Declare an object that contains the whole table as a BizagiArrayList.
- Declare an object to obtain the i-th row (this is optional)
- Obtain the value of the i-th row in a specific column.
Here is an example using the entity-list function:
The following graphic shows what you can obtain from each object in the previous example:
Considerations
Entity-list cannot be used in User Jobs or Start Events
There is a consideration with the entity-list function. This function is contained by the Me object; however, the Me object is related to a work item, which means that a case and a BPMN element must be instantiated.
When you use expressions on exit Start Events, or in User Jobs, there is no work item associated because a case has not been created. Hence, no function from the Me object can be used.
If you need to iterate an entity in any of those scenarios, you have to use the function GetEntitylist.
Array Lists
Some other functions return arrays lists. The way they are iterated is different from Bizagi Array Lists. Now you have to index the i-th record using square brackets [ ] after the name of the object that contains the array. Here are some examples of functions that return Array Lists:
- Me.Assignees
- CHelper.getUsersForPosition
- CHelper.getAssignedWorkItems
- CHelper.getSubProcessesId
Here is an example using the Me.Assignee function:
The following graphic shows what you can obtain from each object in the previous example:
Arrays
Finally, there are few functions that return an Array type object. Like in other programming languages, arrays are iterated differently because Arrays are considered as static data, meaning that the size is fixed. The following functions return Array:
- CEntityManager.GetEntityListWithParameters
- CEntityManager.GetEntity
Here is an example of a function that returns an array:
The following graphic shows what you can obtain from each object in the previous example:
Summary
The following table sums up how you can iterate the different elements using expressions in Bizagi:
Object type | Iteration | How do you get the length | Examples |
---|---|---|---|
Bizagi Array List | Object.get(i).getXPath("Attribute") | Object.size() | GetValuesAsCollection, Me.getXPath(“entity-list(‘’,’’)", parameters), etc. |
Array List | Object[i].Attribute | Object.Count | Me.Assignees, CHelper.getUsersForPosition, CHelper.getAssignedWorkItems |
Array | Object[i].Attributes["Attribute"].Value | Object.length | CEntityManager.GetEntityListWithParameters, CEntityManager.GetEntity |