cancel
Showing results for 
Search instead for 
Did you mean: 

Can Activiti engine do a % process automatically

new-comer
Champ in-the-making
Champ in-the-making
Hi,

We need to have a simple workflow that reviews a workitem. And the review needs to be done based on %, what it means is that if the % is 100%, then all the workitems will be reviewed by the reviewer and if the % is set to 40%, 40% of the work items will be reviewed by the reviewer.

Does Activiti Engin support this kind of configuration? So there is no customized code needed.

Thanks in advance.
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
I'm not sure this is what you are looking for, but since 5.3 version (releasing next week) MultiInstance activities are available. You can for example define parallel loopCharacteristics on a UserTask which causes X number of tasks being created. You can define an expression that is evaluated after every instance of the task are finished, to decide whether or not to continue the other tasks, or to move further in the process flow. This way, you can move further in the flow if 40% of all tasks are finished.

Below is an extract of an Alfresco Parallel review process-definition that leverages the behavior I described above. Joram will add cleaner documentation to the userguide and will be available in the 5.3 release, but this gives you an impression of what is possible:


<userTask id="reviewTask" name="Review Task"
            activiti:formKey="wf:activitiReviewTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if(task.getVariableLocal('wf_reviewOutcome') == 'Approve') {
                             var newApprovedCount = wf_approveCount + 1;
                          var newApprovedPercentage = (newApprovedCount / wf_reviewerCount) * 100;
                         
                          execution.setVariable('wf_approveCount', newApprovedCount);
                          execution.setVariable('wf_actualPercent', newApprovedPercentage);
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
          
           <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${review_assignee}</formalExpression>
                </resourceAssignmentExpression>
           </humanPerformer>
          
           <!– For each assignee, task is created –>
           <multiInstanceLoopCharacteristics isSequential="false">
              <loopDataInputRef>wf_groupMembers</loopDataInputRef>
              <inputDataItem name="review_assignee" />
              <completionCondition>${wf_actualPercent >= wf_requiredApprovePercent}</completionCondition>
           </multiInstanceLoopCharacteristics>
        </userTask>

The variable 'wf_groupMembers' contains a collection of Strings. For each string, a task will be created, having the executionvariable 'review_assignee' set that value, which is used to determine the task's assignee. This causes a task to be created and assigned to every user in the list.

new-comer
Champ in-the-making
Champ in-the-making
Thanks for your reply, I thnk it is what we need, is there a document if we need the details?

jbarrez
Star Contributor
Star Contributor
Yes, 5.3 will contain the best documentation on multi-instance you've ever seen 🙂