Fun with element-templates for Camunda Modeler
The Camunda Modeler mostly does a good job when it comes to modeling processes intuitively. Starting from an Eclipse based solution to the latest stand-alone version, the experience of quickly designing a business process improved a lot.
For all of us who need some extra customization, for example to accelerate input of values in reoccurring tasks, there is a simple way to create and integrate element-templates.
In a recent project we had a process that was called multiple times from call activities, always with different sets of variable values. I call this flavoring. The example in the following process illustrates what I mean.
We used to flavor the sub process using variables defined in the In Mapping, like in the picture:
I must say this is not the strongest feature of the modeler in terms of usability.
Luckily, it offers the possibility of templating it for these purposes. I added the following json to path/of/modeler/resources/element-templates:
{
"name":"Congrats CallActivity",
"id":"de.frena.callactivity",
"appliesTo":[
"bpmn:CallActivity"
],
"properties":[
{
"label":"channel",
"type":"Dropdown",
"binding":{
"type":"camunda:in",
"target":"channel",
"expression":true
},
"constraints":{
"notEmpty":true
},
"choices":[
{
"name":"",
"value":""
},
{
"name":"whatsapp",
"value":"whatsapp"
},
{
"name":"email",
"value":"email"
}
]
},
{
"label":"person to congrat",
"type":"String",
"binding":{
"type":"camunda:in",
"target":"person",
"expression":true
},
"constraints":{
"notEmpty":true
}
},
{
"label":"Called Process",
"description":"the Process Id of the sub process to call",
"type":"String",
"value":"Subprocess_ID",
"editable":false,
"binding":{
"type":"property",
"name":"calledElement"
},
"constraints":{
"notEmpty":true
}
},
{
"label":"business key",
"editable":false,
"type":"String",
"value":"${execution.processBusinessKey}",
"binding":{
"type":"camunda:in:businessKey"
}
},
{
"label": "Asynchronous Before",
"editable":false,
"type": "Boolean",
"value": true,
"binding": {
"type": "property",
"name": "camunda:asyncBefore"
}
},
{
"label": "Asynchronous After",
"editable":false,
"type": "Boolean",
"value": true,
"binding": {
"type": "property",
"name": "camunda:asyncAfter"
}
}
],
"entriesVisible":{
"id":true,
"name":true
}
}
After reloading the modeler you can choose the Element-Template for any Call activity and fill in the values in a more efficient way.
Benefits:
- helps in an environment of reoccurring modelling of the same task.
- helps to easily review entered values with one click on the task.
Tips and Tricks:
- While 'implementing' the json file, the modeler must be restarted after every save of json. To do so, hit F12 Key in modeler. This opens chrome developer tools. Leave them open. Now simply hit Ctrl-R to reload the modeler in a faster more elegant way. Don't forget to save. This Tip I got from Nico Rehwaldt at CamundaCon 2019. Thanks alot!
- Checkout the camunda modeler project and have a look at sample.json for all the possibilites you have.
Let me know what you think and if I can help you to understand this better. This was just a rough nutshell.