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!