Custom fields


I’m trying to export an existing workflow to camunda. I’m creating a flow from code using the fluent API and then open the generated bpmn file in camunda modeler.
In my flow i have a task with a field ‘isTaskCritical’ and value ‘true’ and its a mandatory field.
I’m trying to understand if there is a way (from code) to populate this custom field dynamically so when i open the modeler, in the task, under custom fields i will see the filed filled with the ‘true’ value.
This field’s value can change between different flows so i need to set it dynamically.
I manage to add fields in template using json file but did not see a way to set the fields.
Is there a way of doing that? if not, is there a way of adding validations (mandatory, not empty, etc…) to Input/Output parameters or Extension properties?
Thanks in advance.

Hi @niro we had a glitch yesterday so I’m reposting the thread here:

Hi @niro, The Fluent API isn’t as complete as the Model API and I’m not sure the features you need are available in the Fluent API. You may need to use the Model APIs to add what you need: Joe

Thanks for your reply Joe.
I’ve actually switched to using the regular api.
I could not find in the documentation if what I need to accomplish is possible.
I tried adding, in code, different params (camunda parameter, input and output params), and I can see the fields and values in the modeler once I open the bpmn file, but when I select the template for a specific element (e.g. Task), I can only see the field name and not its value.

Hi @niro could you paste screen shots and code snippets if possible? I’ve got a couple of theories but want to be clear before suggesting something :slight_smile:

But I think you may want to look into Modeler Element Templates:


Hi Joe,
i’ve uploaded a screenshot that has the output param and the field as it is shown in the template.
As you can see, when opening the template, the field named ‘test’ is taking the default value ‘123’ and not the value populated from code ‘111’.
From what i can see in the documentation, i shoudl be using CamundaOutputParameter or CamundaIn since both have ‘source’. Please advise as to what i’m doing wrong here.

If I’m understanding this you’ve created a Modeler element template and generated a bpmn file which you then opened in Modeler? It might be that the template is overriding the model. Can you post your bpmn and your element template json? I can try it out and see what may be happening


Hi Joe,

Thank you for taking the time to help me solving this issue.
Attached are my bpmn file and the json file. At the moment im using the example json file and I’ve just added some code in it to try and see if I can utilize it for my purposes.
The part in the json that is relevant to me here is the one with label=‘test’.


BPMN_FILE.bpmn (11.3 KB) SampleV2_new.json (10.4 KB)

Hi @niro , yes, what I described is what is happening. The model initially displays what was generated (outputParameter with value 111) but then gets overwritten when you apply the element template (outputParameter with hardcoded value of 123). I’m not sure if you can take what was in the original task definition and use it as value in an element template but I’ll have a look.


Hi Joe,

To continue the last example, I see that when I open the bpmn file in the modeler and then open the template and make a change to the value (the default value coming from the template), saving it, and then open the file again, the new value is saved. So i was trying to see how to mimic this behavior from code.
I saw that the difference between the bpmn file before and after making changes using the modeler template is that a new attribute is added to the (in this specific case) ‘Task’ element. The new attribute is camunda:modelerTemplate=“” . the attribute value is taken from the template itself.
SO when I add this attribute manually to the bpmn file before opening it using the modeler, and then opening it with the modeler, the value of the attribute that i added in code, now appears (and not the default value from the template). This is a good behavior for me.
Next step was to try and add this new attribute in code to the ‘Task’ dom element.
I managed to do so, but now the validateModel fails. modelActionElement.getDomElement().setAttribute(“modelerTemplate”,“”);

Do you have any advise on that?


Hi @niro perhaps you should add ‘camunda:’ to the attribute name? As in:


Hi Joe,

I’ve tried that as well.
Adding ‘camunda:’ to the name space gives: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces. This is being thrown when calling ‘setAttribute()’.
Without the ‘camunda:’, the setAttribute() passes, but validation fails with: Attribute ‘modelerTemplate’ is not allowed to appear in element ‘task’.