Setting a class-based execution listener in element templates

Hello,

recently I tried to create element templates for our most common use cases to speed up development of new workflows. Following the documentation this was pretty straight forward for most of my use cases. The only remaining ones were elements which attempt to set an execution listener automatically. Sadly, I was not able to figure out how to do this for class-based execution listener. I only found the option to configure the value as script as well as the scriptFormat.

What I need:

<camunda:executionListener class="path.to.my.class" event="start" />

What I was able to achieve:

<camunda:executionListener event="start">
    <camunda:script scriptFormat="JavaScript">const someVariable;</camunda:script>
</camunda:executionListener>

I appreciate any idea on this, because I would prefer to not refactor my execution listeners.

Kind regards
Adagatiya

Hello again,

I just had some time to look into it in more detail myself.

I discovered that per json schema there is a parameter called “name” for property bindings. Also I was not able to find any restrictions on this parameter. So, in theory, I should be able to use following template to achieve my goal. (Obviously I shortened it for the sake of simplicity)

{
  "$schema": "https://unpkg.com/@camunda/element-templates-json-schema/resources/schema.json",
  "name": "Name",
  "id": "id",
  "version": 1,
  "appliesTo": [
    "bpmn:Task"
  ],
  "elementType": {
    "value": "bpmn:ServiceTask"
  },
  "properties": [
    {
      "label": "Implementation Type",
      "type": "Hidden",
      "value": "path.to.class",
      "binding": {
        "type": "camunda:executionListener",
        "event": "start",
        "name": "class"
      }
    }
  ]
}

The result is the following:

<camunda:executionListener event="start" value="path.to.my.class>
</camunda:executionListener>

By debugging I now discovered there is only special handling for inline scripts. If that is not the case, as in my example, the value will always be set as “value” property. Thus, the configured “name” attribute for the binding is not respected.

Should I create an issue at bpmn-js or which repo would be the correct one? Also, I would be happy to contribute with a pull request for this issue if possible.

Kind regards
Adagatiya

PS.: A good entry point for this issue is the editor action called “applyElementTemplate”.

I was able to identify the bpmn-io/bpmn-js-element-templates repo as responsible for the described behaviour and created an issue over there: Property bindings of type “camunda:executionListener” ignores name property · Issue #13.

In consequence this thread seems solved. A solution will be provided trough the github issue.

Kind regards
Adagatiya

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.