Multi instance

Showing results for 
Search instead for 
Did you mean: 
Member II

Multi instance

Hi Folks

I have a scenario, where I have to create a user task, and it has to be approved by 4 users, say A,B,C,D . How to create the flow. I don't want to create separate 4 user task and then make it parallel. What I want is to create a single user ask , which has to be approved by 4 different users and then it shall move forward. 

If i use multi instance what i need to pass in loop carnality, collection, element variable etc . Please find the screenshot for requirement. 

1 Reply

Re: Multi instance

You can choose to use activiti:candidateGroups. Create a group and all 4 users to the group. When the task starts it goes to the pool. This particular process uses a "pooled assignment". Every user can claim the task and approve it. Once the approval is completed from all 4 users you can mark the task as fully completed.


<serviceTask id="submitDocServiceTask1" name="Submit Document"

               <activiti:field name="script">
                    <activiti:string><![CDATA[execution.setVariable('cmsWorkflow_approveCount', 0);]]></activiti:string>

<userTask id="salesReviewUsertask1" name="My Team Review"
          activiti:candidateGroups="GROUP_My_Team" activiti:formKey="cmsWorkflow:activitiSalesReview">

               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                    <activiti:field name="script">
                                   if(task.getVariableLocal('cmsWorkflow_approveRejectOutcome') == 'Approve') {
                              var finalApprovalCount = cmsWorkflow_approveCount + 1;
                              execution.setVariable('cmsWorkflow_approveCount', finalApprovalCount);


Keep incrementing the count until it reaches 4. Then on the sequenceFlow, write a condition expression which will validate the count before proceeding to next step.


<sequenceFlow id="decisionOnReviewFlow" sourceRef="exclusivegateway1" targetRef="approvedNotificationUsertask">
   <conditionExpression xsi:type="tFormalExpression"><![CDATA[${cmsWorkflow_approveCount == 4}]]></conditionExpression>

If number of users are not defined and a group can have more than 4 users, then use a generic logic. Where get the number of users from the candidate group and use the expression accordingly instead of hardcoded value as 4. 

(ACSCE, AWS SAA, Azure Admin)
Alfresco Process Services Forum
WatchTech Talk Live 143