cancel
Showing results for 
Search instead for 
Did you mean: 

endTask problem

aleksandar1982
Champ in-the-making
Champ in-the-making
Hello,

I have a problem with endTask metod.
I want to create automatic task, but alway get error :this token is locked by token[].
I am not sure where is my mistake.



<event type="task-create">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <runas>admin</runas>
              <script>
                       var task_id="jbpm$"+executionContext.getTaskInstance().getId()
            var task=workflow.getTaskById(task_id);
                task.endTask("Otpremanje");
                   
                   </script>
               </action>
      </event>

Regards
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
Hi,

This looks like code from your process-definition file of workflow.

When you say
task.endTask("Otpremanje");

You must have the transition named Otpremanje  available from the current node where you are inserting this piece of code.

aleksandar1982
Champ in-the-making
Champ in-the-making
I have that transition.
All process working fine without endTask.
Finnaly i found alternative solution.
I add event type="node-leave" with same code as in task-create from abbove and in task-create replace code with executionConte.leaveNode();

Now it's working fine;

Thanx for time Smiley Happy

Best regards

mitpatoliya
Star Collaborator
Star Collaborator
could you please share that piece of code.
So, others can refer as final exact solution to this problem.