AnsweredAssumed Answered

Workflow: auto-assign task to an user

Question asked by benabou on May 26, 2014
Latest reply on May 27, 2014 by benabou
Hi everyone,

I'm new in Alfresco and I have to develop a custom workflow with Activiti.

One of the requirement of it is the usertasks auto-assignement.

In fact, I have an Alfresco group called "Workers".

What I need is to assign my first usertask to the worker with the minimum number of assigned tasks.

I already try to lauch this script before the first usertask in order to get the username of my worker.

But it always returns me the first worker.

var members = people.getMembers(people.getGroup("GROUP_Workers"));
var assignedTasks = workflow.getAssignedTasks();
var arrayCount = [];

for(var i = 0 ; i < members.length ; i++) {
   var name =["cm:userName"];
   for(var j = 0 ; j < assignedTasks.length ; j++) {
      var name2 = assignedTasks[j].properties["bpm:assignee"];

      if (name2 == name) {

var minValue = 999999999999999999999;
var minValueIndex ;

for(var i = 0 ; i < arrayCount.length ; i++) {
   if (arrayCount < minValue) {
      minValue = arrayCount;
      minValueIndex  = i;


In order to debug my code, I already try to put some "logger.log()" after setting this:

But it doesn't write anything.

Please, can someone help me?

Thank you for your help.