For example, there are one exclusivegateway
and two sequenceFlow
.
<sequenceFlow id="flow1" sourceRef="exclusivegateway" targetRef="usertask1">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${approveCount == N}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow2" sourceRef="exclusivegateway" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${approveCount < N}]]>
</conditionExpression>
</sequenceFlow>
Depending on conditions, executed one or the other task.
In business process I want to dynamically calculate the number N
. This number is equal to the sum of all participants of the business process.
(for example, I have two groups and the first group included 10
participants, the second group included 5
. Then N
must be equal to 15
).
Is it possible in Activiti by using JavaScript to calculate the number of participants in these groups?
You could definitely use either JavaScript or Java API for getting the the number of users in a couple of groups. Check this page for JS people API for example: http://docs.alfresco.com/5.1/references/API-JS-getMembers.html
So I imagine a Script task/execution listener before your exclusive gateway, implementing that logic should be the easiest way to do this, as it won't even require restarting the server:
var membersG1 = people.getMembers("GROUP_MY_GROUP1_NAME");
var membersG2 = people.getMembers("GROUP_MY_GROUP2_NAME");
execution.setVariable("N", membersG1.length + membersG2.length);
Note that this is one of many many possible ways for implementing what you specified.