# How to reject a task like used pvm？

**URL:** https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588
**Category:** Uncategorized
**Created:** [May 23, 2017, 10:03am UTC](https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588 "2017-05-23T10:03:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lanlan](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@lanlan](https://forum.flowable.org/u/lanlan)
#### Post date: [May 23, 2017, 10:03am UTC](https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588/1 "2017-05-23T10:03:24Z")

</div>

I was reading a blog of edorasware.  
Flowable 6 introduces a clean and predictable execution model. There’s a one-to-one relationship between BPMN and the execution operations, so all the odd bits of code scattered around the PVM operations are no longer needed.  
so,how to reject a task like used pvm？plz answer me ,im a newer for flowable.  
我在edorasware 的博客上看到，flowable6.0 取消了pvm。那么我现在想要自由的控制流程状态，应该怎么去做呢？

---

<div class="post-metadata">

### Author: ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)
#### Post date: [May 23, 2017, 11:43am UTC](https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588/2 "2017-05-23T11:43:43Z")

</div>

Hi.

I’m not sure if I understand your question correctly.  
What do you mean with ‘reject a task’.  
Perhaps ‘unclaim a task’ (that was claimed)?  
If so; that can be done with the Java API;

`TaskService.unclaim(String taskId);`

which is a shortcut for;

`TaskService.claim(String taskId, String userId);`

(Where userId is null for unclaim)

Regards,

Yvo

---

<div class="post-metadata">

### Author: ![lanlan](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@lanlan](https://forum.flowable.org/u/lanlan)
#### Post date: [May 24, 2017, 2:27am UTC](https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588/3 "2017-05-24T02:27:31Z")

</div>

Hi .  
i want to perform a specified task whick is different from the next task in sequence flow;In flowable 5,i can do this by using PVM to set next task dynamically;  
As shown in the process,the normal execution steps are as follows:start-\>task1-\>task2-\>task3-\>end.But in the implementation of the task 3 ,user found some problems during the process that only resolved by re-execute task1.How can i do it to achieve my purpose? there none branch.

![](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/flowable/original/1X/1e7c5fb5ddff663ac01689b5e057869e61dd9da0.jpg)

in flowable5 or activty ,i can use Pvm to reset process runing to task1. like this:  
ActivityImpl currActivity = ((ProcessDefinitionImpl) definition)  
.findActivity(currTask.getTaskDefinitionKey());  
List nextTransitionList = currActivity  
.getIncomingTransitions();  
// 清除当前活动的出口  
List oriPvmTransitionList = new ArrayList();  
List pvmTransitionList = currActivity  
.getOutgoingTransitions();  
for (PvmTransition pvmTransition : pvmTransitionList) {  
oriPvmTransitionList.add(pvmTransition);  
}  
pvmTransitionList.clear();

```
        // 建立新出口
        List<TransitionImpl> newTransitions = new ArrayList<TransitionImpl>();
        for (PvmTransition nextTransition : nextTransitionList) {
            PvmActivity nextActivity = nextTransition.getSource();
            ActivityImpl nextActivityImpl = ((ProcessDefinitionImpl) definition)
                    .findActivity(nextActivity.getId());
            TransitionImpl newTransition = currActivity
                    .createOutgoingTransition();
            newTransition.setDestination(nextActivityImpl);
            newTransitions.add(newTransition);
        }
        // 完成任务
        List<Task> tasks = taskService.createTaskQuery()
                .processInstanceId(instance.getId())
                .taskDefinitionKey(currTask.getTaskDefinitionKey()).list();
        for (Task task : tasks) {
            taskService.complete(task.getId(), variables);
            historyService.deleteHistoricTaskInstance(task.getId());
        }
        // 恢复方向
        for (TransitionImpl transitionImpl : newTransitions) {
            currActivity.getOutgoingTransitions().remove(transitionImpl);
        }
        for (PvmTransition pvmTransition : oriPvmTransitionList) {
            pvmTransitionList.add(pvmTransition);
        }
```

---

<div class="post-metadata">

### Author: ![lanlan](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@lanlan](https://forum.flowable.org/u/lanlan)
#### Post date: [May 25, 2017, 6:05am UTC](https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588/4 "2017-05-25T06:05:48Z")

</div>

Hi .  
i want to perform a specified task whick is different from the next task in sequence flow;In flowable 5,i can do this by using PVM to set next task dynamically;  
As shown in the process,the normal execution steps are as follows:start-\>task1-\>task2-\>task3-\>end.But in the implementation of the task 3 ,user found some problems during the process that only resolved by re-execute task1.How can i do it to achieve my purpose? there none branch.

---

<div class="post-metadata">

### Author: ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)
#### Post date: [May 25, 2017, 4:03pm UTC](https://forum.flowable.org/t/how-to-reject-a-task-like-used-pvm/588/5 "2017-05-25T16:03:04Z")

</div>

Why not use an exclusive gateway and have a sequence flow back to task 1 when the user finds a problem in task 3 (ie. set a variable when completing task 3 that is used for the expression on the sequence flow)?
