cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to update the tenant id of a task. setTenantId() doesnt work

vamsimp
Champ in-the-making
Champ in-the-making
Hello,

1. We have a process instance created using the tenant id, and we are trying to update the tenant id of the tasks inside the process instance so that people belonging to a different tenants could work on the tasks. We are doing this due to a business requirement but unfortunately we are not able to update the tenant id. We are using the below code for updating the tenant id.

               Task task = taskService.createTaskQuery().taskId("100").list().get(0);
                task.setTenantId("newTenantId");
      taskService.saveTask(task);

We checked the saveTask() implementation in the TaskEntity class and it looks like it does not update the tenant id of a task.
Am I missing something here? is it not possible to udpate the tenant id of a task?

Thanks in advance.
5 REPLIES 5

hari
Star Contributor
Star Contributor
Hi Vamsi,

As far as I understood about multi tenancy in Activiti, you will have to set the tenant while deploying the BPM. So when you start the BPM and when the tasks get generated, they will be associated to that tenant. I dont think setting the tenant Id in the above mentioned way would work.

vamsimp
Champ in-the-making
Champ in-the-making
Thanks Hari. So does that mean, once a process instance is created with a tenant id, all the tasks in the proc instance will have the same tenant id and it is not possible for tasks within the proc inst have different tenant ids?

hari
Star Contributor
Star Contributor
Yes. Thats true. All the tasks for that process instance will only be related to a specific tenant.

vamsimp
Champ in-the-making
Champ in-the-making
I was able to update the tenant id of the task. It wont be possible to update the tenant id after the task is created, but you could do it while the task is being created. I was able to do it by implementing the ActivitiEventListener interface and overriding the OnEvent method. You could listen to the task created event and do the necessary.
So that way, I was able to set different tenant ids for tasks inside a single process, even though the process level tenant is different than the one I am setting

trademak
Star Contributor
Star Contributor
Hi,

When a task is part of a process instance, we don't allow you to change the tenant id on a task level with the Activiti API. The whole process instance is part of a specific tenant. With the API we currently only support changing the tenant id for a whole deployment. But it's easy to add a custom SQL update statement to change the tenant id of course.

Best regards,
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.