Assign Task to Multiple users using API

1
0
-1

Hi Folks,

I have an external application which access bonita using API calls. I have a list of users and I want to assign a task to multiple users - any one can complete it. How can I do this using API ?
http://documentation.bonitasoft.com/javadoc/api/7.0/org/bonitasoft/engin...(long,%20long) provides API to assign a task to only one user. My requirements is to assign a task to multiple users so that any one can complete the task.
Please help me on this.

Comments

Submitted by tugaknight on Mon, 09/28/2015 - 16:43

I'm fairly sure that you can't assign multiple users to the same task.

However a new task should start unassigned and what I do is fetch all the tasks (applying the relevant filter) and only show the tasks which have no assigned_id (i.e., no user has it assigned to him/her) and when the user takes the task I assign it before redirecting him to the form page.

3 answers

1
0
-1

Hello,

So with Antoine help, I made an "auto-assign + Submit form" button.

I just created a Custom Button, by copying pbButton properties.

Here is the code I added for auto-assign task :

this.action = function action() {
          var request = $http({

                    method: "put",
                    url: "../API/bpm/humanTask/"+ $scope.properties.taskId,
                    data: {
                        "assigned_id" :$scope.properties.userId 
                    }
                }).then(function successCallback(response)
                {
                    sleepFor(500);
                }, function errorCallback(response)
                {
                    console.log("error " + angular.toJson(response, true));
                });
  }

function sleepFor (sleepDuration) {
    var now  = new Date().getTime();
    console.log("Attente de la fin du sleepFor");
    while(new Date().getTime() < now + sleepDuration)
    {
        /* Do nothing */ 
    }
    submit();
}

submit() function is the default pbButton function.

1
0
-1

Hi,

I'm currently encountering the same problem. I have a task which can be performed by several people (all present in the same group).

I have no problem to create an Actor Filter, but it seems not to be enough. As soon as I try to validate my form, which is accessed by a link in an e-mail (while connected with a user present in the Filter group, of course), I have this error :

org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException: The activity is not yet assigned, unable to execute it

How can I execute the step you're inidcating : "Using the API you can update the process variable and ask for filter to be re-executed"?

Comments

Submitted by antoine.mottier on Mon, 11/02/2015 - 10:52

When a task can be performed by several users (the "candidates") a single user need to take (claim) the task.

Such operation is mandatory. If user try to submit a task (i.e. ask for task execution) before claiming the task, he will get the "The activity is not yet assigned, unable to execute it" error.

Claiming a task can be done:

  • In Bonita Portal using the "take" button
  • Using Java API
  • Using REST API: PUT operation on HumanTask resource to update "assignee_id" attribute.

So my suggestion would be to create an application page that will take care of task assignation and redirection to the form. Task assignation can either be done automatically or confirmation can be ask to the user by providing a button. Alternatively you can include a button to claim the task in the task form.

A button to claim the task (and optionally to redirect to form page) can be done using custom widget feature. Here is a code snippet to do the task assignation:

var request = $http({
                    method: "put",
                    url: "../API/bpm/humanTask/"+ $scope.properties.taskId,
                    data: {
                        "assigned_id" :$scope.properties.userId 
                    }
                });
                // Store the data-dump of the FORM scope.
                request.success(
                    function( response ) {
                        console.log("sucecss",response);

                    }
                );
                request.error(
                    function (response){
                        console.log("error",response);

                    }                
                );

1
0
-1

Hi,

First I think that it is important to understand that a task can be done by a "set of users/candidates" until one user "take/claim/assign to him self" the task.

The "set of users/candidates" can be define using one of the two following options:

  • Actor mapping: you mapped the actor (that is just an id) declared in the process definition to the Bonita organization (e.g. a group of users, a set of specific users...) That mapping can be update live after deployment for all running and future process instances.

  • Filters: a filter is executed when the task become ready and override actor mapping. The filter will create a list of users ids that define who can perform the task.

For your use case, I recommend to create a custom user filter. This user filter will use a process variable that define the list of candidates. Using the API you can update the process variable and ask for filter to be re-executed.

Comments

Submitted by tcarmo20 on Thu, 11/24/2016 - 14:01

I'm using Bonita Community 7.3.2.
I have a task that has an actor filter defined. This actor filter returns 3 users.
I understand that a task is then ready to be claimed by one of the 3 users.

What is the API that gives the information identifying that that specific task can only be claimed by those 3 users and giving that information about those users?

Submitted by antoine.mottier on Wed, 12/07/2016 - 13:50

Hi,

getPossibleUsersOfPendingHumanTask is the API that let you retrieve the list of users that can perform a given task.

This API is not yet available as a REST API so you might need to create a REST API extension if you want to use it from a form.

Notifications