It’s very simple and cool. for my project I can not use property panel and camunda providers, for this problem I create custom model with this config:
{
"name": "Collaboration variables payload",
"uri": "http://www.graphinfotec.com/schema/xml/variables",
"prefix": "var",
"xml": {
"tagAlias": "lowerCase"
},
"types": [
{
"name": "ElementVariables",
"superClass": [
"Element"
],
"properties": [
{
"name": "variables",
"isMany": true,
"type": "Variable"
}
]
},
{
"name": "Variable",
"properties": [
{
"name": "id",
"type": "String"
},
{
"name": "name",
"type": "String"
},
{
"name": "title",
"type": "String"
},
{
"name": "value",
"type": "String"
}
]
}
],
"emumerations": [],
"associations": []
}
and in code I used: [Complete code]
this.modeler = new BpmnJS({
container: '#designer-canvas',
keyboard: {
bindTo: window
},
moddleExtensions: {
var: {
"name": "Collaboration variables payload",
"uri": "http://www.graphinfotec.com/schema/xml/variables",
"prefix": "var",
"xml": {
"tagAlias": "lowerCase"
},
"types": [{
"name": "ElementVariables",
"superClass": ["Element"],
"properties": [{
"name": "variables",
"isMany": true,
"type": "Variable"
}]
},
{
"name": "Variable",
"properties": [{
"name": "id",
"type": "String"
},
{
"name": "name",
"type": "String"
},
{
"name": "title",
"type": "String"
},
{
"name": "value",
"type": "String"
}
]
}
],
"emumerations": [],
"associations": []
}
}
});
and in any element I used:
var ElementVariables = _moddle.create('var:ElementVariables');
_rootElement.businessObject.extensionElements = _moddle.create('bpmn:ExtensionElements');
_rootElement.businessObject.extensionElements.get('values').push(ElementVariables);
ElementVariables.variables = [];
$.each(result.data, (i, item) => {
var _variable = _moddle.create('var:Variable', {
id: `${item.Id}`,
name: item.Name,
title: item.Title,
value: ''
});
ElementVariables.variables.push(_variable);
});
and worked successfully for me
I hope helped you (sorry for bad english)