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 = members.properties["cm:userName"];
arrayCount.push(0);
for(var j = 0 ; j < assignedTasks.length ; j++) {
var name2 = assignedTasks[j].properties["bpm:assignee"];
if (name2 == name) {
arrayCount++;
}
}
}
var minValue = 999999999999999999999;
var minValueIndex ;
for(var i = 0 ; i < arrayCount.length ; i++) {
if (arrayCount < minValue) {
minValue = arrayCount;
minValueIndex = i;
}
}
execution.setVariable("userName",members[minValueIndex].properties["cm:userName"]);
In order to debug my code, I already try to put some "logger.log()" after setting this:
log4j.logger.org.alfresco.repo.workflow=debug
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug
But it doesn't write anything.Please, can someone help me?Thank you for your help.