# How to get next task in task complete listener

**URL:** <https://forum.flowable.org/t/how-to-get-next-task-in-task-complete-listener/2895>\
**Category:** Flowable Engine\
**Created:** [November 13, 2018, 3:14am UTC](https://forum.flowable.org/t/how-to-get-next-task-in-task-complete-listener/2895 "2018-11-13T03:14:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clinan](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@clinan](https://forum.flowable.org/u/clinan)\
**Post date:** [November 13, 2018, 3:14am UTC](https://forum.flowable.org/t/how-to-get-next-task-in-task-complete-listener/2895/1 "2018-11-13T03:14:58Z")

</div>

Hi  
I want notificate next user by sms after current activity task completed.But I dont know how get get next task.  
Thanks for you help.  
clinan

---

<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:** [November 13, 2018, 2:44pm UTC](https://forum.flowable.org/t/how-to-get-next-task-in-task-complete-listener/2895/2 "2018-11-13T14:44:18Z")

</div>

Hi,

When the current user task is completed you can do a TaskQuery with the TaskService to get the next Task. Or do you need this logic inside the process instance? Then you could use a TaskListener with a create event for example ([https://flowable.org/docs/userguide/index.html#taskListeners](https://flowable.org/docs/userguide/index.html#taskListeners)), and send the SMS as part of the TaskListener logic.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![clinan](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@clinan](https://forum.flowable.org/u/clinan)\
**Post date:** [November 13, 2018, 3:40pm UTC](https://forum.flowable.org/t/how-to-get-next-task-in-task-complete-listener/2895/4 "2018-11-13T15:40:31Z")

</div>

Hi tijs,  
I was finish this work with the method.

```auto
ExpressionManager expressionManager = springProcessEngineConfiguration.getExpressionManager(); 
for (SequenceFlow flow : outgoingFlows) {
   String expression = flow.getConditionExpression(); 
   if (expression == null || expression.trim().equals("")) { 
      return flow.getTargetFlowElement();
   }
   VariableContainerWrapper variable = new VariableContainerWrapper(processVariables);
   Object value = expressionManager.createExpression(expression).getValue(variable);
   if (value instanceof Boolean) {
       if ((Boolean) value) {
         return flow.getTargetFlowElement();
       } else { 
         throw new FlowableIllegalArgumentException("expression error"); 
   }
 }
```
