Assign task to user on form submit

Hi!

I’d need to be able to select the user that a task will be assigned to in several tasks of the project. For example, in the start task, I have the following select:

To fill the select, I make a call to the API in the ‘variables-fetched’ event of the camForm. What I’d like is that, when the user clicks on the ‘Complete’ button and the ‘submit’ event is fired, make an API call to the API to change the assignee and, when it’s done, continue with the process. So this is what I tried:

camForm.on('submit', function(evt) {
    $scope.assignTask($scope.assignedUserId).then(function successCallback(response) {
        // NOTE: assignTask makes a call to POST 'engine://engine/:engine/task/' + camForm.taskId + '/assignee'
        
        // Continue with the process
    }).catch((error) => {
        // Error
    });
});

This is the error I get:

Cannot submit task form 28f4eae7-1c12-11ea-8fb0-2e09ebac4323: ENGINE-03005 Execution of ‘DELETE TaskEntity[28f4eae7-1c12-11ea-8fb0-2e09ebac4323]’ failed. Entity was updated by another transaction concurrently.

Any suggestion? Thanks!

Hi @felipRR

Completing a task means the task would be deleted. How come that you need to assign the task to someone else where it would not be available when complete action is submitted.

May you describe your use case with a little bit details

Hi!

Thanks for your response, now I understand that my approach is not correct. I’ll try to explain what I need to do:

  • Let’s say that we start a process and we are in the initial task, called ‘Retrieve agreement data’. In this task, we need to display a dropdown with the available users in the system. My intention is that, when a user is selected, the next task in the flow must be assigned to him. We need this because we want to assign the task to an specific user manually, and not wait until he/she claims it.

I hope that explained it well. Any suggestion for this?

Edit

I’m doing some tests with task listeners and I think that I have everything I need to make it work as we want. I’ll post an update when I try it better.

Cheers!

Hi @felipRR I have a similar use case as you do, could you please share your insights on how you implemented this? :smiley:

When starting your process, take a process variable to say “assignee” and assign the assigner to this variable then call the process start method (api ).
And in your BPMN file take expression in Assignee ${assignee} so it should work. Runtime this value will be replaced with assignee you passing while starting process.

So what happens here is that when the previous task is completed, this variable value is captured and set, and so the next task automatically uses the value for the variable to set the assignee.

@pradeep.poojari @felipRR
Do you have any thoughts on how this may take shape if there is a known “role” of user that needs to be assigned to the task, but the specific user id needs to be fetched from a business logic outside of camunda? In my case I have this sample workflow as shown below.

Once the process starts, we want to set the user for general manager by executing a business logic outside of camunda. And we also want to sync up the app database so that a notification could be sent to the user when the task has been assigned to them. (I have documented this question in more detail here Integration with React app)

Hi @johnjacobkenny , In your “General Manager approval” add a Task Listener, something like the below image. In that Task Listener class call your external api by sending “Task ID” as a parameter and then in your external service take this task id and write a logic to get “assignee” then call Camunda api from there with Task id and assignee to assign this particular task.

2 Likes

@pradeep.poojari thank you so much, this clarifies it for me. I will give it a try.