cancel
Showing results for 
Search instead for 
Did you mean: 

Assign task to usergroup from serviceTask

leohorn
Champ in-the-making
Champ in-the-making
Hello,

i have searched the forums and documentation high and low, but could not find a solution….

I am running the activiti engine from within spring, no problem. I have a process flow whereby if a task isn't completed by an agent in time it is escalated to a supervisor. The supervisor can either then complete the task, or assign it back to the agents' task pool, where it can be claimed again by an agent.

I cannot see how I can get a handle to the task id in order to reassign it back to the group from within a service task. From within the spring controller form, I can do it using the following code:

public ModelAndView releaseTask(
                    @RequestParam(value = "claimTaskId", required = true) String claimTaskId
                    ){
        taskService.setAssignee(claimTaskId, null);

But I don;t want to be using the spring controller to be doing this. It's not how the process is modelled. The engine should be doing it, otherwise it doesn't represent what is actually modeled in the workflow. What is actually modelled is that the supervisor makes a choice and one of those choices is that the java service task does the actual setting of the groupAssignee. (the choice of course being modeled by an exclusive gateway)

I've used the JavaDelegate class:

public class Foo implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        System.out.println("In the ActivitiUtilities Class");
        System.out.println("execution id " + execution.getId());
}

but if i try and set the task back like so:

     taskService.setAssignee(execution.getId(), null);

I get an error telling me that the task with that ID cannot be found.

I'm assuming that the taskId either changes on each step, or I need to somehow get a handle to the DelegateTask object instead, or that when using service tasks I need the workflow ID, not that for the task?

I'm a little confused, and help would be appreciated. Thanks.


2 REPLIES 2

trademak
Star Contributor
Star Contributor
How did you implement the escalate logic in the process definition? Because when you are executing the service task logic, the user task isn't there anymore, or did you define a cancelActivity="false" on a boundary event? If the user task is still there, you should execute a task query to retrieve the task id. An execution id is a different id.

Best regards,

leohorn
Champ in-the-making
Champ in-the-making
Many thanks for your reply.

It was because I had neglected to set the cancelActivity="false" in the boundary event as you suggested. I was over thinking the problem.

Thanks for the help, really appreciate it.