Hello, dear community!
I need to get a lot of users (as objects, not usernames) in ScriptTaskListener inside my userTask. Users shoud have the same organization name with initiator. How can i get them? Is it possible?
What i want:
1) Get all users existing in my system.
2) Filter them using "organization" field (must equals to initiator.property.organization).
3) Distribute filtered users (their userNames, I think) to execution variables based on their groups.
4) Put necessary variable into activiti:candidateUsers of my userTasks.
I will be gratefull for any tips or solutions of the issue.
Code fragments:
<userTask id="myTask1" name="01. My Task 1"
activiti:assignee="${initiator.properties.userName}"
activiti:formKey="ilm:customSimpleForm">
<extensionElements>
<activiti:taskListener event="create"
class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
execution.setVariable('bpm_sendEMailNotifications', true);
task.setVariable('bpm_sendEMailNotifications', true);
var dueDate = new Date();
dueDate.setDate(dueDate.getDate() + 5);
task.dueDate = dueDate;
// Get users here, filter and distribute. For example:
// execution.setVariable('assignees_from_group_a', userNamesStringFromManagers);
// execution.setVariable('assignees_from_group_b', userNamesStringFromWorkers);
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
...
<userTask id="myTask2" name="02. My Task 2"
activiti:candidateUsers="${assignees_from_group_a}"
activiti:formKey="ilm:customSimpleForm">
...
...
</userTask>
...
<userTask id="myTask3" name="03. My Task 3"
activiti:candidateUsers="${assignees_from_group_b}"
activiti:formKey="ilm:customSimpleForm">
...
...
</userTask>