Extension properties

HI Stephen

Kindly share an example of creating custom “Local Variables” ?
I was trying to add a “Property” using “Extensions” for a task in a BPM process. Is it the same as your advice ?

We need to use custom forms when tasks are referred to by external system. So, we need to store something like an “externalFormId” per task.

Many Thanks !

I just noticed that there are no “Extensions” or “Add Property” for tasks / activities in CMMN.

We need this solution to work similarly for both BPM processes, and CMMN.
How can I create custom variable for each task, and access it using REST API ?


Specifically for your Custom Forms use case, have you looked at the Form Key field?

When a external system gets a task, the form key is returned which is any string you provide.

if there are other variables that you are storing, please provide further examples.

Thanks Stephen.

Yes, I did explore the formKey field.
I can store an external Id there which the other system can fetch through REST API.

But IMHO, that limits any future capability where we would like to use “embedded forms” when accessing the same flow withing Camunda. Is there a way that I can use embedded forms, along with passing a custom Id to an external system using formKey ?
I am new to Camunda. Kindly correct me if I am wrong in my understanding.

Thanks & Regards,

1 Like

Interesting use case. Have you thought about just storing a mapping between the formkeys and the external system forms. Could even use camunda dmn for this.

The formId that we need to store is very specific to an external system. So, the same needs to be returned to the calling system one way or the other.

Yes, I explored using DMN table as a mapping table. However, I guess that would need 2 API calls.
One on the task, and then a second API call on the DMN to get the corresponding externalFormId.
Ideally, we would like to achieve it in a single REST API call.

Kindly advise if my understanding of Camunda system is correct.

@nitin I do not think you can do what you want, without at least 2 API calls.


No way to create custom variables for a task that may be exposed to the API ?


Not variables that are stored as Task Properties. You have to do what @Philipp_Ossler mentioned.

You are trying to merge two concepts together (external forms, and embedded Forms) when they were not designed to support both at the same time.

The external system is managed by a separate team.
I would still like to retain some level of control in the long term :slight_smile:

Nevertheless, I did try with Extensions and Process Properties as well.
However, one, they are not accessible in the API.
Also, that is not an option with CMMN
Multiple tasks in a process or case complicates it even further.

I think we should consider giving it as an option where the user might want to have custom properties defined at any level (tasks / activities / BPM process / CMMN case, etc.)

Many thanks for your inputs Stephen and Philipp.

Let me try some workarounds if there is no straight jacket way to handle this !

Best Regards,

@nitin you could create some middleware to do the double API call / logic between camunda and the external system. You could deploy this on the same camunda server as a JAX-RS or just build as some sort of microservice.

This seems like a good idea, Stephen. Thanks for the tip !

I’ll continue my research into all the workarounds, and let’s see what’s the best that I can come up with.

Building and deploying a middleware to handle this scenario could take a while. I am under pressure at the moment to deliver a workable solution quickly.

Many Thanks for all your inputs Stephen.
Appreciate the time that you’ve put in for this discussion!

Thanks & Regards,

@nitin you could build this middleware as a node app in a few hours. see the example: Using/building a "webhook server" for Post /message for a webhook pattern.

Very interesting.
Would I need to additionally setup a NodeJS server for this, Stephen ?

Yes. But you can do this with a docker container. Or just install node on a server.

Any idea that you might have to setup a quick installation on top of existing Tomcat / Wildfly that we use for Camunda, for setting up the middleware ?

Deploy a Process Application and expose a endpoint using JAX-RS. If you search around in the forum and in the docs, you should see the examples of how to create process applications

Thanks for the tip, Stephen.
I am already doing some research around this after your message.

Let me see the best that I can come up with.

Thanks again for all your help !

Best Regards,

Hi Philipp_Ossler,

I get this error message when I try to cast execution.getBpmnModelElementInstance() to Startevent.

class org.camunda.bpm.model.bpmn.impl.instance.UserTaskImpl cannot be cast to class org.camunda.bpm.model.bpmn.instance.StartEvent (org.camunda.bpm.model.bpmn.impl.instance.UserTaskImpl and org.camunda.bpm.model.bpmn.instance.StartEvent are in unnamed module of loader 'app')

Do you have any suggestions to what I can do?

@tsr95 UserTaskImpl is not a type of StartEvent, it should be type of UserTask. You can’t assign to incompatible types, because activity behavior is different for both model instances.

It’s returning a type of UserTask and not the StartEvent