javascriptbpmnbpmn-js

Can changing the condition of a sequence flow changes its name? [BPMN-JS]


I’m using “bpmn-js” and “bpmn-js-properties-panel” and my goal is to make sure that when a sequence flow’s condition changes, its name changes as well.

This is my code:

case "commandStack.element.updateProperties.executed":
            {
              const shapeType = event.context.element.type;

              if (shapeType === TYPES.SEQUENCE_FLOW) {
                if (event.context.properties.conditionExpression) {
                  if (event.context.properties.conditionExpression.body)
                    event.context.properties.name =
                      event.context.properties.conditionExpression.body;
                  else event.context.properties.name = "";
                }
              }
    }
    break;
case "commandStack.element.updateModdleProperties.executed":
            {
              const shapeType = event.context.element.type;

              if (shapeType === TYPES.SEQUENCE_FLOW) {
                if (event.context.properties.body !== "") {
                  event.context.moddleElement.$parent.name =
                    event.context.properties.body;
                } else event.context.moddleElement.$parent.name = "";
              }
            }
            break;

Is this the right mode? I have a problem in the second case, because when changing the Inline Script the name changes but not the label above the arrow. Probably because the event to update the label doesn’t start, what can I do?


Solution

  • Resolved by Bpmn-js: An example of using the command interceptor - #2 by philippfromme