cancel
Showing results for 
Search instead for 
Did you mean: 

Complete task from Script task Listener

sarkar92
Champ in-the-making
Champ in-the-making
is it possible in activiti something like this to complete task

<userTask id="usertask1" name="All your base are belong to us">
         <extensionElements>
            <activiti:taskListener event="assignment" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
               <activiti:field name="script">
                  <activiti:string>
                        delegateTask.getExecution().getEngineServices().getTaskService().complete(delegateTask.getId());
                     </activiti:string>
               </activiti:field>
               <activiti:field name="language" stringValue="groovy" />
               <activiti:field name="resultVariable" stringValue="myVar" />
            </activiti:taskListener>
         </extensionElements>
      </userTask>
7 REPLIES 7

sarkar92
Champ in-the-making
Champ in-the-making
sorry ignore above post ….

is it possible in activiti something like this to complete task …

<code>
<userTask id="usertask1" name="All your base are belong to us">
   <extensionElements>
    <activiti:taskListener event="assignment" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
     <activiti:field name="script">
      <activiti:string>
                delegateTask.getExecution().getEngineServices().getTaskService().complete(delegateTask.getId());
               </activiti:string>
     </activiti:field>
     <activiti:field name="language" stringValue="groovy" />
    </activiti:taskListener>
   </extensionElements>
  </userTask>

</code>

sarkar92
Champ in-the-making
Champ in-the-making
please help

sarkar92
Champ in-the-making
Champ in-the-making
anyone know about this

frederikherema1
Star Contributor
Star Contributor
It's not possible to complete the task which is currently being assigned from within a task-listener. This is due to the fact that the task-listener is actualy working on the task you want to see completed. What is your actual use case?

sarkar92
Champ in-the-making
Champ in-the-making
thanks for your reply..

Actually i have created a approval process.
In that approval process there may 5 approvers but more that 50% approval required(means minimum 3 approval required).
So  what if the process initiator is one of the approver… thats way i try to complete task within the taskListener .

frederikherema1
Star Contributor
Star Contributor
Okay, I think you should model this into your process (manager has veto-rights) instead of trying to fix this in a listener. One option is to set a special variable from within a task-complete listener in case the manager has approved. Then, use this variable in your Multi-instance completion condition on the review-task declaration.

sarkar92
Champ in-the-making
Champ in-the-making
got it….
thanks a lot