Hello,
I defined some properties in a json-file, which are attached by the context-menu.
But when I save and reload the diagram, the properties are not saved.
This is how the properties will be set. The alert command signals, that the properties are set correctly
bpmnModeler.on('element.contextmenu', (event) => {
event.originalEvent.preventDefault();
event.originalEvent.stopPropagation();
({ element } = event);
// ignore root element
if (!element.parent) {
return;
}
const businessObject = getBusinessObject(element);
const { bpmnType } = businessObject;
let { BusinessContext } = businessObject;
let { TaskId } = businessObject;
if(bpmnType == "bpmn:SemanticTask") {
BusinessContext = bc.value;
TaskId = ti.value;
alert(BusinessContext);
alert(TaskId);
ST.classList.remove('hidden');
}
});
Furthermore I use a submit-button which should actually save the properties with serialize-function:
formST.addEventListener('submit', (event) => {
event.preventDefault();
event.stopPropagation();
bpmnModeler.on('comments.updated', serialize);
bpmnModeler.on('commandStack.changed', serialize);
bpmnModeler.on('element.contextmenu', serialize);
bpmnModeler.on('canvas.click', function() {
bpmnModeler.get('comments').collapseAll();
});
ST.classList.add('hidden');
});
and finally, my save-Function:
var $download = $('[data-download]');
function serialize() {
bpmnModeler.saveXML(function(err, xml) {
var encodedData = err ? '' : encodeURIComponent(xml);
$download.attr({
'href': encodedData ? 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData : '',
});
if (err) {
console.log('failed to serialize BPMN 2.0 xml', err);
}
});
}
As I mentioned in the beginning, when I click on my Save-Button: The diagram is downloaded without the properties, which were set before over context-menu.
Thanks very much in advance!