Change ID on Element Type Change

Listening to the shape.changed event now. This was the way to go from the beginning. An issue was that I couldn’t find an overview of possible events. I found one by logging the eventBus which will show all possible listeners.

bpmnModeler.get('eventBus').on('shape.changed', function (event) {
		var id = event.element.id;
		var type = event.element.type;
		  
		if (type === 'label') {
			return;
		}
		  
		var newID = type.substring(type.indexOf(':') + 1) + '_' + id.substring(id.indexOf('_') + 1);
		
		if (id == newID) {
			return;
		}
		
		modeling.updateProperties(event.element, {id: newID});
	});
2 Likes