cancel
Showing results for 
Search instead for 
Did you mean: 

Task Reassign

7joeblack8
Champ in-the-making
Champ in-the-making
Hi there,


assuming i'm in Alfresco 4.2.x environment, i just can't figure out how to reassign a task using Javascript API.

can anybody provide an example to clearify?

many thanks!
5 REPLIES 5

7joeblack8
Champ in-the-making
Champ in-the-making
I add that my goal is to reassign a task to a group. Actually now i can use activiti:candidateGroups but, i would decide inside a task using complete Listener, to assign the new task to a specific Group.

Or maybe calling a create listener in the same task i would reassign…

trademak
Star Contributor
Star Contributor
For a candidate group bpm:assignee is not the right variable to use, that's a String which you can use to assign a task directly to a person. Did you take a look at the example Alfresco process definitions?
Invoking a Java class in that way is just fine, so something else is probably wrong. But that's hard to say without the full process definition. Also be aware that Log4J doesn't do anything when you use System.out.println. Als a Java class name typically starts with a capital letter.

Best regards,

7joeblack8
Champ in-the-making
Champ in-the-making
Well i've tried many attempts after reading manual userguide.

this solution doesn't worked for me..:

http://forums.activiti.org/content/reassign-task-another-user

also tried through a ScriptListener fired before a ServiceTask goes to the UserTask (which has the tag activiti:candidateGroups="${bpm_assignee}"  in bpmn…)i want to manage with something like:


var userName = "admin";
var user = people.getPerson(userName);
var model.groups = people.getContainerGroups(user);
<!–  Task Assigner List<String> users = [ 'test', 'admin'] as String[];–>
execution.setVariable('bpm:assignee', model.groups);
   

but i get:

org.activiti.engine.ActivitiIllegalArgumentException: Expression did not resolve to a string or collection of strings      


i've also tried the Manual Attempt. It says that if the tag activiti:candidategroups or the humanperformer aren't enough it is possible to obtain the reassignment via delegate with a script java-backed.

So i made , just to test the delegate first, this simple delegate:


package com.test.activiti;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;

public class executeDelegator  implements JavaDelegate {

  public executeDelegator() {

   System.out.println("test delegate ok");

  }

 
  public void execute(DelegateExecution arg0) throws Exception {

   System.out.println("Activiti Log Fired!");

  } 
  
}

put it in the webinf\lib, then i tagged my user task like this:

<serviceTask id="alfrescoScripttask1" name="TestScript Task" activiti:class="com.test.activiti.executeDelegator "></serviceTask>
the workflow doesn't warn and went well if i pass through this task, but no log is affected.
I  put log4j declaration of this class to Debug as the usual logger to read in alfresco.log my system.out that i put in javascript listeners.

Maybe i have to register spring bean of my delegate?

When i manage to workout from this, i'm in the right direction to change the task assignee group through Javascript?

many thanks

7joeblack8
Champ in-the-making
Champ in-the-making
Hi! finally i did it….thank you so much!

7joeblack8
Champ in-the-making
Champ in-the-making
i'll try next to pass a variable from task to assign the value given from the task before…stay tuned!