Assigning user_id to a task that is not yet reached

1
0
-1

Hello. Im working on a workflow. At some point a manager user receives a case, and should select from a list of subordinates on its department to continue attending the case. The problem I'm facing is that the humanTask/userTask rest api doesn't seem to return the task until it has been reached in the workflow. Maybe it doesn't exist prior to that.

How would you do this ? Right now im using a hack, where the subordinate task exists from the beginning but is assigned to an unused actor. It becomes apparent to the receiving user when it is reassigned by his manager. I don't like this solution, and I'm sure it's not the proper way to do this.

Thanks in advance for your inputs.

Greetings. Jose.

3 answers

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

You have to use an actor filter for this. If there is only one user that should be assigned to the task you can use the 'unique user' actor filter on the tasks to pick a single user. You have to store the id of the user in a process or business variable at the start of the case.

If you need to select multiple users belonging to the Actor you can develop a custom Actor filter. Before starting developing a custom actor filter make sure that a static actor mapping cannot solve your use case.

HTH

Romain

Comments

Submitted by romain.bioteau on Thu, 06/25/2020 - 13:58

I've made a contribution that you can use for your use case here

Submitted by rosario.latagan... on Fri, 06/26/2020 - 03:08

Thank you sir. I just came upon your actor filter and to works! I was having trouble with creating custom filters, as I'm not well versed with the programming languages of Bonita.

Submitted by jherraez on Thu, 07/02/2020 - 15:44

Thanks. I believe this would have been even better than the solution i finally adopted. I stored the selection in a process variable and used an engine api call from a groovy script in the connector in section of the receiving task.

The method is apiAccessor.processAPI.assignUserTask(activityInstanceId, desiredUserId)

Greetings.

1
0
-1

Hello,
You can use the selected user as 'assigned user' with an actor filter.
I already do this filter:
filter input : 'users' => List

/**
 * 
 */
package com.ecervo.actorfilter;

import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.engine.connector.ConnectorValidationException;
import org.bonitasoft.engine.filter.UserFilterException;
import org.bonitasoft.engine.identity.User;

/**
*The actor filter execution will follow the steps
* 1 - setInputParameters() --> the actor filter receives input parameters values
* 2 - validateInputParameters() --> the actor filter can validate input parameters values
* 3 - filter(final String actorName) --> execute the user filter
* 4 - shouldAutoAssignTaskIfSingleResult() --> auto-assign the task if filter returns a single result
*/
public class DynamicActeursImplcx extends AbstractDynamicActeursImplcx {

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

    @Override
    public List filter(final String actorName) throws UserFilterException {
        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();
    
    }

}

Hope it's help, regards

1
0
-1

Hello, I believe you can use the method getPossibleUsersOfHumanTask(long processDefinitionId, String humanTaskName, int startIndex, int maxResults). You can use a connector and save the result to a process variable.

Notifications