As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
How can I set a list users (e.g. in a comma delimited string) as candidate assignees? I am passing the list to the start form with the process-instance API and attempting to use an expression in the candidate property on the user task.
For Enterprise Edition, I use the following script task (groovy) code snippet in BP3's Activiti Basic training to demonstrate this exact scenario.
The example uses the userService to get all users and iterate over the result, but you can use the same technique on a comma separated list passed into the process:
import com.activiti.domain.idm.User;import com.activiti.security.SecurityUtils;out.println('Start - Init');User currentUser = SecurityUtils.getCurrentUserObject();ArrayList idList = new ArrayList(); Long tenantId = currentUser.getTenantId();List<User> users = userService.getAllUsers(0,999,tenantId);for (User u : users) { idList.add(String.valueOf(u.getId()));}execution.setVariable('assigneeList', idList);out.println('End - Init');
import com.activiti.domain.idm.User;import com.activiti.security.SecurityUtils;
out.println('Start - Init');User currentUser = SecurityUtils.getCurrentUserObject();ArrayList idList = new ArrayList(); Long tenantId = currentUser.getTenantId();
List<User> users = userService.getAllUsers(0,999,tenantId);for (User u : users) { idList.add(String.valueOf(u.getId()));}
execution.setVariable('assigneeList', idList);
out.println('End - Init');
Once you have a list of user ids assigned to a process instance variable, simply set the candidate users to reference the list:
If you are using Community Edition, the approach is exactly the same but instead of using userService you would use identityService.
Hope this helps,Greg