Updating element name from properties panel



I’m adding a custom property to the properties panel, and I’d like to have the name of each element update to match my custom property when its set method is called. My code works for task elements, but not intermediate events. The labels for intermediate events don’t update unless I refresh the page. I’ve seen answers to similar questions refer to Modeling.updateProperties(), but I don’t know how to get a reference to the modeling object in the context of the set method. Also, my code seems to do something very similar: the command object that gets returned gets passed to the command stack just like Modeling.updateProperties(). Am I missing something?

import entryFactory from 'bpmn-js-properties-panel/lib/factory/EntryFactory';
import cmdHelper from 'bpmn-js-properties-panel/lib/helper/CmdHelper';
export default function(group, element, customOptions) {
	element.options = customOptions;
    	id: 'WorkflowObject',
    	label: 'Workflow Object',
    	dataValueLabel: 'workflowLabel',
    	selectOptions: getOptions,
    	modelProperty: 'workflowObject',
    	emptyParameter: false,
    	setControlValue: true, 
    	get: function(element, node) {
    		var o = findSimpleObject(element, node);
    			return {'workflowObject' : o.id, 'workflowLabel': o.name};
    		return {'workflowObject' : '', 'workflowLabel': ''};
	  	set: function(element, values, node) {
	      var bo = getBusinessObject(element);
	      var so = findSimpleObject(element, node, values.workflowObject || '');
	      var boProperties = {};
	      bo.workflowObject = values.workflowObject;
	      var commands = [];
	    	  bo.name = so.name;
	    	  boProperties['name'] = so.name;
	    	  boProperties['workflowObject'] = values.workflowObject || '';
	    	  commands.push(cmdHelper.updateBusinessObject(element, bo, boProperties));
	      return commands;



Is there any reason you monkey-patch the businessObject name before executing the actual update?

   bo.name = so.name;
   boProperties['name'] = so.name;

It might be that the update is not triggered anymore, as no change in the name is recognized.


Hi nikku, thanks for your response. That’s a good point, the monkey-patching was redundant. However, I removed the direct assignments to bo.name and bo.workflowObject and I’m still seeing the same behavior.

I also noticed that if an event element already has a label, when I modify my custom property, the label updates correctly. So it seems we need to tell the element to initialize its name label. Is there a way to trigger that through the command stack?


Please update to the latest version of bpmn-js, if you’re using the 2.x line already. This should fix numerous bugs, including labels not being created when changing the name the way you do it.