Add extension elements with any type (i.e. camunda:inputOutput)


I would like to generate following model:

      <camunda:inputParameter name="assigneeEntity">user</camunda:inputParameter>

Here is what I am doing:

var userTaskMoodle = ...;
var extensionElementsMoodle = moddle.create('bpmn:ExtensionElements');
var inputOutputMoodle = moddle.createAny('camunda:inputOutput', '');
var inputParameterMoodle = moddle.createAny('camunda:inputOutput', '', {
  name: 'assigneeEntity'
inputParameterMoodle.body = 'user';
inputOutputMoodle['camunda:inputParameter'] = inputParameterMoodle;
extensionElementsMoodle['camunda:inputOutput'] = inputOutputMoodle;
userTaskMoodle.businessObject['extensionElements'] = extensionElementsMoodle;

And this is the result:

  <bpmn:extensionElements />

What am I doing wrong?

1 Like

bpmn:ExtensionElements contains individual members in the value property.

Refer to the meta-model descriptor for details.

So in order to properly add it into the BPMN 2.0 document, you need to add the camunda:inputOutput like this:

// use ModdleElement#get('propertyName')
// to safely access a collection property

1 Like

Hi nikku,

How am I supposed to put camunda:inputParameter moddle under camunda:inputOutput;
This is not working:


Is this because I created these custom moddles with createAny() method?

Inside AnyTypes, i.e. elements create with moddle.createAny(...) the two special properties $body and $children allow you to wire child elements.

What it boils down to is something like this:

var inputParameter = moddle.createAny('camunda:inputParameter', camundaNs, {
  name: 'assigneeEntity',
  $body: 'user'

var inputOutput = moddle.createAny('camunda:inputOutput', camundaNs, {
  $children: [


I added a test case that should illustrate the details.

1 Like

Hi nikku,
may you can help me understanding this? I want to do the same thing as the topic writer…
I do it your way and it works very fine.

But here is my problem. I want to read the input/output parameters after setting them.

var elementRegistry = modeler.get('elementRegistry');
var elementRegistryEntry = elementRegistry.get(;
var elementRegistryEntryBO = elementRegistryEntry.businessObject;


all fine…
but if I save my xml and load it new, $children is undefined. then i need to access this way:


So first I can access them via $children and after reloading the xml i need to do it via values…

That causes another problem. I additional save an attribute “type” to my inputParameter. If I reloaded my existing xml into the modeler, the “type” is lost.

<camunda:inputParameter type="ABC" name="ANYNAME">ANYNAMEVALUE</camunda:inputParameter>

its very annoying to have always a different structure of my businessobject, just cause i recently added my parameters or loaded an xml where i added the parameters before…

Thanks for your help!

The $children property is exposed for generic elements for which bpmn-js does not know the internal structure.

The fact that you don’t have $children but rather actual typed elements is due to the fact that you made bpmn-js aware of it (most likely by including camunda-bpmn-moddle). In that case you must not create an AnyType but rather the camunda:InputOutput element directly:

var inputOutput = moddle.create('camunda:InputOutput', { ... });

// use similar to any type
// recognize that it has actual instance properties

And by the way: Please do not necrobump old topics. Instead link to this thread from new topic.

1 Like