User Tasks etc. doesn't work for custom Tasks

Hello,
I just noticed that for Custom Tasks (Tasks with CustomRenderer), the options to make them to User Tasks and other which can be selected by the screw-wrench symbol, is not more possible. So, nothing happens when I want to assign a Custom Task to a user task, for instance. How could I fix that?

Please share a running / prototypical example that clearly shows what you’re trying to achieve, what is working and what is not.

Use our existing starter projects to quickly hack it or share your existing, partial solution on GitHub or via a CodeSandbox. Provide the necessary pointers that allow us to quickly understand where you got stuck.

This way we may be able to help you in a constructive manner.

Thanks :heart:

The sandbox I also provided in my other thread should be suitable: https://ocy2u.csb.app/

Then when you click on a SemanticTask (the Element with S Symbol), it should be possible to make this to a User Task, for instance by clicking the screw wrench Symbol in the ContextPad.

I noticed that you set businessElement.bpmnElement in your CustomContextPad and it’s never removed when element is replaced. Then, the condition this.getType(element) === "bpmn:SemanticTask" will always be met which makes your CustomRenderer return the SemanticTask shape.

Hmm , is there a suggestion how I could do it better? The if condition is to distuingish from normal Tasks Elements. So I honestly have no idea at the moment

When you replace element via the Context Pad, it fires moddle.canCopyProperty to find out whether properties of the element should be copied to the new element. You could implement a listener for this event to disallow ST:bpmnElement property in user tasks or any other type. Have a look at this CodeSandbox to see what really happens: https://codesandbox.io/s/cranky-lehmann-yzgc9

I can’t find a difference between your CodeSandbox and the CodeSandbox I posted before? If I understand you correctly, I have to disallow ST:bpmnElement in user tasks?
How could I do this, which code do I have to modify?

This fragment of code displays the XML after every change and then the context of moddle.canCopyProperty event. The XML proves that tasks are replaced indeed while the context allows you to implement your solution. Then, you could modify the event listener to return false in case of replacing the Semantic Task with user task.

    bpmnModeler.on("elements.changed", () => {
      bpmnModeler
        .saveXML({ format: true })
        .then(({ xml }) => console.log("new xml:", xml));
    });

    bpmnModeler.on("moddleCopy.canCopyProperty", (context) =>
      console.log("moddle.canCopyProperty payload:", context)
    );

I’ve changed the CodeSandbox to include some naive solution:


    bpmnModeler.on("moddleCopy.canCopyProperty", (context) => {
      if (
        context.property === "bpmn:SemanticTask" &&
        context.parent.$type !== "bpmn:Task"
      ) {
        return false;
      }
    });

Thanks very much. Is there also a possibility, that the semanticTask keeps
its rendering but gets the additional Symbol for User Task when replacing to it?