Joget DX Beta Available for Download

Check out Joget DX, the next generation successor to Joget Workflow for faster, simpler digital transformation.

Page tree
Skip to end of metadata
Go to start of metadata

你可以使用下面这段代码将其放入  匹配Bean Shell匹配参与者与用户.中。



import java.util.Collection;
import org.joget.workflow.shark.model.dao.WorkflowAssignmentDao;
ExtDirectoryManager directoryManager = (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
WorkflowAssignmentDao workflowAssignmentDao = (WorkflowAssignmentDao) AppUtil.getApplicationContext().getBean("workflowAssignmentDao");
//set groupId
String groupId = "G-001";
//Get users of the group using directory manager, sorted by firstName
Collection userList = directoryManager.getUsers(null, null, null, null, groupId, null, null, "firstName", false, null, null);
String assignTo = "";
int lowestAssignmentCount = -1;
Collection assignees = new ArrayList();
//loop through the users
for(Object u : userList){
	User user = (User) u;
	//get open assignment count of the current user
	//refer to to refine search conditions
	int userAssignmentSize = workflowAssignmentDao.getAssignmentSize(null, null, null, null, u.getUsername(), "open");
	//System.out.println(u.getUsername() + " has " + userAssignmentSize);
	if(lowestAssignmentCount == -1){
		//assign to the first person first
		lowestAssignmentCount = userAssignmentSize;
		assignTo = u.getUsername();
	}else if(userAssignmentSize < lowestAssignmentCount){
		assignTo = u.getUsername();
		lowestAssignmentCount = userAssignmentSize;
//System.out.println("Will assign to " + assignTo);
return assignees;
  • No labels