Updating label without using "updateProperties()" for sequenceFlow

while updating the name of the sequenceFlow, by updating the businessObject(e.g., element.businessObject.name = ‘xyz’), the object gets updated but the same is not reflected in the canvas.

and when using updateProperties, we are facing challenges doing undo & redo.

Please suggest any other way to update the name of the sequence flow

1 Like

What are the challenges you’re facing by using updateProperties?

There is a scenario where we have a custom property panel and the label of sequenceFlow.

when I update the property in custom property panel, the updated property should be shown as label for sequence flow, as well as the generated xml should be updated with the custom property.

There are two steps involved

  1. update the property panel which should be updating the xml.
  2. update the sequence flow label.

Both steps use ‘updateProperties’ api to get the xml with updated property and for label updation in sequence flow.

But from user perspective it is only custom property panel change. When he changes property , sequence flow name should be updated as per user entry.

eg: customPropValue = “expression - 1”; (updating a value in custom property panel)
Expectation: it should be reflected in xml as well as label for sequence flow.
Current: it is reflected in xml but not label of sequence flow.

When do an undo operation for one time, it should revert both the xml change as well as label of sequence flow

How do you expect the custom property to show up as the label of the connection? Is it supposed to be the actual label?

Yes. The requirement is to show the user entered property as name/label of the sequence flow, similar to the below diagram/example (“book is loan” & “book is available” label/name of sequence flow)

image

Why do you need a custom property then?

Because, the label should be the data entered by user. which means, the label is not static and hence its dynamic.
And user can changes it using the custom property.
And the action can be done n-number of times.

can someone suggest any solution?

So if I understand correctly you want the label to be updated whenever the user changes that custom property?

Yes. Exactly. And should look like one action

You’d need a command interceptor that updates the label whenever your custom property was updated.

Here’s an example: https://codesandbox.io/s/bpmn-js-computed-label-8hfe7

The example

  • adds a model extension that allows sequence flows to have a score attribute
  • adds a command interceptor that sets the sequence flow label to Score: {score} whenever the score attribute is changed
  • add interaction to edit the score attribute

Note that using a command interceptor is a way of executing additional commands before or after a particular command is executed. These additional commands will also be reverted when the original command is reverted. From the users point of view there’s only one command. Pressing CmdOrControl+Z once will undo all commands.

Does this help you?

Thanks.
Looking into the reference shared by you.

If any further queries, I will be posting again.