Assign Instances of a Task to All Members of Organization Group

1
0
-1

Hello everyone,

I am working on a project where every user in a group of the organization must send a quarterly form, and I am having trouble figuring out how to assign an instance of the task to every user in the group. I have selected parallel multi-instantiation for the task, but I don't know how to set up a dynamic amount of instances depending on the organization's size and how to assign these multiple instances to individual corresponding members of the group.

Any help would be greatly appreciated,

Regards

Comments

Submitted by delphine.coille on Fri, 01/03/2020 - 17:25

Hola Miguel,

Before answering I have a quick question about your use case. You say that the amount of instances depends on the organisation's size. But does that change when you send the form (I mean during the process instance) or it is subject to change inbetween?

Submitted by miguel.aguilera... on Wed, 01/08/2020 - 03:48

Hello,

When I wrote the question the amount of instances was subject to change as more users entered the organization. However, I have approached the issue a different way.

The caveats of the project I'm working on means that the members of the organization will need to register through a form/app to be able to access their tasks and portal, and so the registration process instantiates the tasks as the users register via a groovy script executed in a system task.

1 answer

1
+1
-1
This one is the BEST answer!

Hello Miguel,

To do that, you need to initialise a variables that contain all your users.
Somethink like that:

import org.bonitasoft.engine.identity.UserCriterion

List users =apiAccessor.identityAPI.getUsers(0, 9999, UserCriterion.FIRST_NAME_ASC)
return users;

After that, you need to create your iteration task on this variable.

To assign a task to a specific user, you need to create an ActorFilter.
In this filter, you need to specify one or more users in entry.
I allready do a filter to do that, take a look at this Filter implementation (my entry parameters is a list of users named 'users').

public class DynamicActeursImpl extends AbstractDynamicActeursImpl {

@Override
public void validateInputParameters() throws ConnectorValidationException {
//TODO validate input parameters here

}

@Override
public List filter(final String actorName) throws UserFilterException {
//TODO execute the user filter here
//The method must return a list of user id's
//you can use getApiAccessor() and getExecutionContext()

List users =(List)getUsers();
List userIds = new ArrayList();
for (User user : users) {
userIds.add(user.getId());
}
return userIds;

}

@Override
public boolean shouldAutoAssignTaskIfSingleResult() {
// If this method returns true, the step will be assigned to
//the user if there is only one result returned by the filter method
return super.shouldAutoAssignTaskIfSingleResult();

}

}

So now, just use this filter on your task ;)

Regards,

Comments

Submitted by miguel.aguilera... on Wed, 01/08/2020 - 21:05

Fantastic, thank you!

Notifications