# taskService.complete ends the workflow

**URL:** <https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334>\
**Category:** Flowable Engine\
**Created:** [February 22, 2017, 4:43pm UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334 "2017-02-22T16:43:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [February 22, 2017, 4:43pm UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334/1 "2017-02-22T16:43:04Z")

</div>

When I complete a task (taskService.complete(taskId)) , with wrong variables(variables decide the next task in the workflow. this ends the processInstance…

When I set correct variables, the workflow moves to the next task correctly…

I am expecting to error when complete the task with wrong variables as it can’t decide the next task in the workflow. Instead it ends the workflow…

Please advice…

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [February 23, 2017, 8:34am UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334/2 "2017-02-23T08:34:04Z")

</div>

Hi,

I need a bit more details about what you are trying to do and how your process definition (BPMN XML) is implemented. Flowable doesn’t end the process instance when “wrong” variables are passed to it.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [February 23, 2017, 12:15pm UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334/3 "2017-02-23T12:15:57Z")

</div>

I have two user tasks usertask1 and usertask2, there are more tasks in the sequence…  
These two tasks are connected with the sequenceFlow with an expression as below…

```
 <sequenceFlow id="toUserTask1" name="Reject To UserTask1" sourceRef="usertask1" targetRef="usertask2">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approve == 'true' }]]></conditionExpression>
</sequenceFlow>

```

When I complete the userTask1 with approve=false… processInstance ends…

I was expecting taskService.completeTask errors out as the outcome can’t be determined with supplied information… Instead it completes and logs entire processintance data to history tables, the act\_hi\_procinst.end\_act\_id\_ is having the “userTask1”…

Let me know if you need more info

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [February 23, 2017, 1:48pm UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334/4 "2017-02-23T13:48:13Z")

</div>

Hi,

Having a condition on the only one outgoing sequence flow from user task 1 to user task 2 is not good. If there’s only one sequence flow it should not have any condition. If you would use an exclusive gateway and have multiple outgoing sequence flows, conditions are the way to choose the next step in the process.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [February 24, 2017, 10:04pm UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334/5 "2017-02-24T22:04:24Z")

</div>

Say if we have two or three outgoing sequence(each having a condition) from user task1 , and when completing the user task1 if the required variables are not supplied the processinstance is ending instead of throwing error…

We can catch this exception outside of process engine, but want to know how to avoid the situation of ending the processinstance before it reaches the endpoint…

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [February 26, 2017, 10:12am UTC](https://forum.flowable.org/t/taskservice-complete-ends-the-workflow/334/6 "2017-02-26T10:12:35Z")

</div>

Can you share the BPMN XML so we can reproduce the issue? Let us know all steps you are performing in detail. I’m expecting something different is happening, but really have to understand all the details.

Best regards,

Tijs
