cancel
Showing results for 
Search instead for 
Did you mean: 

Modified Parrarel Workflow

nunuts
Champ in-the-making
Champ in-the-making
Hi guys

I'm working on a workflow and need your advice. I'm creating a modified parrarel workflow and my requirement is when one of assigness rejects the workflow, the workflow will stop without waiting for other assignees. Is possible and if it is, how can i achieve it?


Thank You  Smiley Very Happy
9 REPLIES 9

afaust
Legendary Innovator
Legendary Innovator
Hello,

this is possible in both jBPM and Spring. You need to incorporate a system action when the user choses to reject his/her task, which will withdraw the task(s) assigned to (the) other assignee(s). In jBPM you can achieve this through e.g. through a jBPM script on the "rejected" transition that looks up the other tasks and signals an appropriate transition on it.

Regards
Axel

lyles
Champ in-the-making
Champ in-the-making
To get that behaviour in the out-of-box Parallel Review and Approve workflow you just have to set the Required Approval Percentage to 100%. As soon as one reviewer rejects it, the completion condition is met and the workflow flows back to the originator as a rejection.

afaust
Legendary Innovator
Legendary Innovator
@lyles: This is correct, but only for the Activiti-based out-of-the-box parallel review & approve workflow - the jBPM one does not behave in this manner.

nunuts
Champ in-the-making
Champ in-the-making
Thank for replay for both of you
@AFaust
this is possible in both jBPM and Spring. You need to incorporate a system action when the user choses to reject his/her task, which will withdraw the task(s) assigned to (the) other assignee(s). In jBPM you can achieve this through e.g. through a jBPM script on the "rejected" transition that looks up the other tasks and signals an appropriate transition on it.
If you don't mind, can you gime a sample code ? Smiley Happy

afaust
Legendary Innovator
Legendary Innovator
Hello,

an example based on jBPM script would be:


<transition name="join" to="completeExecutionBranches">
            <script>
                <expression><![CDATA[
                    /* end parallel tasks in a for-loop */
                    /* NOTE: The current task is one of those tasks, so our "parent" token is the root for the forks */
                    Collection children = token.getParent().getChildren().values();
                    for (Token child : children) {
                        /* NOTE: don't mess up the current token */
                        if (child.getId() != token.getId()) {
                            /* NOTE: "end" must be a valid transition */
                            Collection tasks = taskMgmt.getUnfinishedTasks(child)
                            for (TaskInstance task : tasks) {
                               task.end("end");
                            }
                        }
                    }
                ]]></expression>
            </script>
</transition>
[/code]

This example assumes you only have one task between your fork and join, and which has a valid transition namend "end".

Please note: For the tasks ended by this script, the current user is automatically set as the modifier / owner of the task and no (additional) data is being set in the tasks. If there are mandatory task properties to be filled, this may fail if they have not yet been set.
You should also be fairly familiar with the jBPM engine in general (not just how you use it in Alfresco) when you work with the jBPM core like this.

Regards
Axel

nunuts
Champ in-the-making
Champ in-the-making
Hello,

an example based on jBPM script would be:


<transition name="join" to="completeExecutionBranches">
            <script>
                <expression><![CDATA[
                    /* end parallel tasks in a for-loop */
                    /* NOTE: The current task is one of those tasks, so our "parent" token is the root for the forks */
                    Collection children = token.getParent().getChildren().values();
                    for (Token child : children) {
                        /* NOTE: don't mess up the current token */
                        if (child.getId() != token.getId()) {
                            /* NOTE: "end" must be a valid transition */
                            Collection tasks = taskMgmt.getUnfinishedTasks(child)
                            for (TaskInstance task : tasks) {
                               task.end("end");
                            }
                        }
                    }
                ]]></expression>
            </script>
</transition>
[/code]

This example assumes you only have one task between your fork and join, and which has a valid transition namend "end".

Please note: For the tasks ended by this script, the current user is automatically set as the modifier / owner of the task and no (additional) data is being set in the tasks. If there are mandatory task properties to be filled, this may fail if they have not yet been set.
You should also be fairly familiar with the jBPM engine in general (not just how you use it in Alfresco) when you work with the jBPM core like this.

Regards
Axel[/quote]

Thank you for your reply  😛

webfrank
Champ in-the-making
Champ in-the-making
Hi, I just tried your solution but when I choose that transition I got error 500. I have a simple parallel workflow and I would like to cancel all pending tasks when one of the approver reject the document without waiting all the others.
I have only a task inside fork-join, task transitions are "reject" "approve", both to "endreview" but with "approve" which increment approveCount.
I'm using Alfresco 4.0c Community. Any help is really appreciated.

mitpatoliya
Star Collaborator
Star Collaborator
what is the error you are getting in your logs when you do this.
That may be because your target node is not present.
Also have you tried with action class?

webfrank
Champ in-the-making
Champ in-the-making
Hi, this is the error I got:

org.alfresco.service.cmr.workflow.WorkflowException: 011116857 Failed to signal transition reject from workflow task jbpm$137493.
Returning 500 status code

What do you mena for target node? The transaction "to" node? It exists, in my WF this is the code:

<transition name="reject" to="endreview">
            <script>
            Collection children = token.getParent().getChildren().values();
            for (Token child : children) {
               if (child.getId() != token.getId()) {
                  Collection tasks = taskMgmt.getUnfinishedTasks(child);
                  for (TaskInstance task : tasks) {
                     task.end("reject");
                  }
               }
            }
            </script>
      </transition>

and

<join name="endreview">
      <transition to="isapproved" />
   </join>

is the target node.

I'm just now trying with action class but I'm not sure how to get "taskMgmt" instance.