AnsweredAssumed Answered

Assign task to usergroup from serviceTask

Question asked by leohorn on Dec 27, 2013
Latest reply on Jan 2, 2014 by leohorn
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.


Outcomes