cancel
Showing results for 
Search instead for 
Did you mean: 

UserTask auto complete

partizano
Champ in-the-making
Champ in-the-making
Hi, Activiti Team!

Is in activiti any way to do user tasks that auto complete themselves? I tried to do that in listener implementation of user task, and in parallel service task, but it doesn't work…

Thanks
10 REPLIES 10

trademak
Star Contributor
Star Contributor
Hi,

Why would you want to autocomplete a user task? Why not use a service task then?

Best regards,

partizano
Champ in-the-making
Champ in-the-making
I want that user task auto completes only if some condition = true. And I need that when condition is not true, user task mustn't auto completes…

mathiasd
Champ in-the-making
Champ in-the-making
Maybe you should use an exclusive gateway. If the condition is satisfied,  move to a service task (automatic), else move to a user task (non-automatic).

partizano
Champ in-the-making
Champ in-the-making
I think, exclusive gateway is not the solution. I will try to describe, what I need:
I have one service task, that do long operation. While running this operation exceptions may occur. After exception is rasied I need that user can start service task manually, again. And I need that first time service task will start automatically, without user actions. So I tried to develop process like this:
[attachment=0]simple process.png[/attachment]
If I will make that "Start service task" will complete automatically (at first time) - when in "Service Task" exception will be raised "Start service task" will be active and user can complete it (ie run service task) again.

Maybe, there is another way to do what I need, but I don't know how to do it, yet…
Maybe, there is way in activiti diagram to detect, if exception is raised or not?

mathiasd
Champ in-the-making
Champ in-the-making
Is your service task a Java service task ?
You can detect if an exception in thrown and then choose the appropriate flow : http://www.activiti.org/userguide/index.html#serviceTaskExceptionHandling


public void execute(ActivityExecution execution) throws Exception {
    PvmTransition transition = null;
    try {
      //… YOUR TASK HERE …
      transition = execution.getActivity().findOutgoingTransition("no-exception");
    } catch (Exception e) {
      transition = execution.getActivity().findOutgoingTransition("exception");
    }
    execution.take(transition);
  }
}

partizano
Champ in-the-making
Champ in-the-making
Thanks a lot, seems it should work!

But I can't understand one moment… First of all, I am using Activiti 5.6, yet. In Activiti 5.6 PvmTransition class is situated in package org.activiti.engine.impl.pvm. But there is no such package in Activiti 5.7 (in java docs), although in Activiti 5.7 user guide this class is mentioned… Is there class PvmTransition in the Activiti 5.7?

mathiasd
Champ in-the-making
Champ in-the-making
I don't know, I just quoted the 5.7 user guide. Actually I'm using Activiti 5.6 too Smiley Wink
But it should exist something similar in 5.7

partizano
Champ in-the-making
Champ in-the-making
Dear Activiti Developers!

Is there something like org.activiti.engine.impl.pvm.PvmTransition in Activiti 5.7?

jbarrez
Star Contributor
Star Contributor
The class surely exists. But the impl packagages have been removed from the javadoc generation.