cancel
Showing results for 
Search instead for 
Did you mean: 

Transition ID

fordville
Champ on-the-rise
Champ on-the-rise
Using the Javascript API, I'm wanting to simply endTask for an adhoc workflow.  According to the API it should go something like:

endTask(transition_id);  //but this doesn't do much good if I can get the value of the transition ID!

Here's what I have in end_task.get.js:

      taskId = args.task_id;  //no problem
      task = workflow.getTaskById(taskId);  //no problem
      //need transition_id here!
      if (task != null)  {
         task.endTask(transition_id);
      }

Despite hours of combing the boards and Google, I found nothing that will get me the correct transition_id from a task instance. 

This might fall into the items that I've read about that are unavailable in the Javascript API.  If someone can confirm that we can't transition from one task to the other with the Javascript API, that will be a great help. 

I could really use an assist on this one!

Thanks!

Bruce
5 REPLIES 5

mitpatoliya
Star Collaborator
Star Collaborator
Hi fordville,

you can transit with the help of javascript api.
In your script you don't need any thing extra you can do it like.

task.endTask("Approve");

"transition_id" you can put hard coded its nothing but the id for transition which you have specified in you process definition for given task.

fordville
Champ on-the-rise
Champ on-the-rise
It is that same for adhoc transitions?  I did

task.endTask("Task Done");

which did not work.

Any ideas?

Bruce

mitpatoliya
Star Collaborator
Star Collaborator
To give you more idea let say we have workflow in following task

<task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">        
        </task>
        <transition name="approve" to="approved" />
        <transition name="reject" to="rejected" />
    </task-node>

and We want to do approve transition then we have to use.

task.endTask("approve");

Then it will transit to approved state.

vincy
Champ in-the-making
Champ in-the-making
To give you more idea let say we have workflow in following task

<task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">        
        </task>
        <transition name="approve" to="approved" />
        <transition name="reject" to="rejected" />
    </task-node>

and We want to do approve transition then we have to use.

task.endTask("approve");

Then it will transit to approved state.

hi,

    where can i add task.endTask …in process definition… can u pls share your code

<transition to="Reject" name="Reject">
      
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                             <script>
                         task.endTask("Reject");
                     </script>
                 </action>
      </transition>

is it right….

mitpatoliya
Star Collaborator
Star Collaborator
well something like that only not sure about the syntex.
But you it should be part of alfresco java script.
for more such APIs you can refer this wiki link
http://wiki.alfresco.com/wiki/Workflow_JavaScript_API