Is it possible to associate a workflow using REST API for a new tenant created using REST API

In processes.xml, two tenantId are used to associate certain workflows specific to tenant
for example tenantId=tenant1 , resources -> tenant1_workflow.bpmn and tenantId=tenant2 , resources -> tenant2_workflow.bpmn , and using rest api an option is given to create tenants , now how to associate resources/workflow to this tenant? Is it possible?

Hi @manojkatarip,

I hope that I have understood your question correctly.

When you set the tenantId attribute within the deployment descriptor (processes.xml), the deployment is restricted to the given tenant.

If you want to achieve the same goal by using the REST API, it is necessary to create a tenant first (as you already mentioned) [1]. Afterwards you can create a new deployment with the given tenantId [2] so the deployment is restricted to this tenant.

I hope this answers your question.

Cheers
Tassilo

[1] https://docs.camunda.org/manual/7.7/reference/rest/tenant/post-create/
[2] https://docs.camunda.org/manual/7.7/reference/rest/deployment/post-deployment/

1 Like

Yes understanding is correct
Basically trying to develop different workflows for different tenants
also next step would be to dynamically change the workflow itself (is this also possible using REST APIs?) if its possible

Okay. Thank you. I’ll try this one (deployment REST APIs) Hope it works/ inline with our objective

Hi @manojkatarip,

what exactly do you mean with workflow? Whenever you change the process definition, all running instances must be handled in a proper way.

Besides file based process definitions (*.bpmn) you can also use the Fluent Builder API [1] to create process definitions more dynamically.

Cheers
Tassilo

[1] https://docs.camunda.org/manual/7.7/user-guide/model-api/bpmn-model-api/fluent-builder-api/

1 Like

Hi @tasso94

By workflow, I meant, process definition.
Thank you for this input.

Hi @tasso94

I have the same question but I’d like to assign a tenant to a running process instance. I’ve checked the rest API and I couldn’t find anything that I could use to do that…

Also, would that be possible to assign the tenant based on a field in the form, for example (in this case, mostly for new instances) ?

Thanks !

Hi @fcordova,

sorry for the late response.

It’s not possible to assign a tenant to a process instance. However, you can specify a tenant id on creating a deployment.

Does this answer your question?

Cheers,
Tassilo

Hi @tasso94…

It does, although it’s not the answer I expected… :smiley:

I have some people running a process in an organisation and now I have to add some more organisations and users, but I don’t want users from org A to have access to anything from other organizations and, eventually, I may have to “transfer” between organisations (although it’d be a more administrative action). Creating tenants seems to be just the right solution, isn’t it ?

So, the problem is that I already have instances running without any tenant information and they are visible to everybody.

Would it be reasonable to change the tenant in the database (at least until a rest API is released) ? By “reasonable” I mean something like “just change the value of field ACT_XYZ.tenant to the tenant id you want”…

Thanks anyway

Hi Flavio,

I took a closer look into your problem and here is my proposal:

  1. Make sure that you have set the engine’s history level to “FULL” [1]
  2. Delete the running process instances without a tenant id
  3. Implement and add a tenant id provider to the process engine configuration [2]
  4. Restart your previously deleted process instances [3]

Let me know what you are thinking about this approach.

Cheers,
Tassilo

[1] https://docs.camunda.org/manual/7.8/user-guide/process-engine/history/#set-the-history-level
[2] https://docs.camunda.org/manual/7.8/user-guide/process-engine/multi-tenancy/#instantiate-a-shared-definition
[3] https://docs.camunda.org/manual/7.8/user-guide/process-engine/process-instance-restart/