Can i copy whole node with data of it?

for each instance of the node, I save a lot of data using the modeler, I would like to be able to copy not just the xml representation of the node, but all the data related to it, can I achieve this behavior?

example how i set data to node:

    const setIntoXml = (fieldType: string, value: any) => {
        const modeling = modeler.get('modeling')
        modeling.updateProperties(element, {
            [fieldType]: value,
        })
    }

Can you try to explain again what you’re trying to do? What is the high level goal?

when writing to a node, I call the context menu (PropertiesPanel), in which I can enter some settings for each node.

My goal is that when I select a node that has any data populated and press cntrl+c followed by cntrl+v. A full copy of the node was inserted on the working canvas, including the data filled in for it was inside.

Have you created a model extension for your custom data? Otherwise your custom data won’t be recognized and not copied when using copy & paste.

i have it

here is a small example of my model

{
    "name": "custom",
    "uri": "http://custom/ns",
    "associations": [],
    "types": [
        {
            "name": "NodeProps",
            "properties": [
                {
                    "name": "inputsNumber",
                    "isAttr": true,
                    "type": "String"
                },

                {
                    "name": "modelType",
                    "isAttr": true,
                    "type": "String"
                },
                {
                    "name": "messageAppeal",
                    "isAttr": true,
                    "type": "String"
                },
                {
                    "name": "lastMessageAppel",
                    "isAttr": true,
                    "type": "String"
                },
....

and connect like this

bpmnViewerRef.current = new Modeler({
            container,
            keyboard: {
                bindTo: document,
            },
            moddleExtensions: {
                custom: customModdleExtension,
            },
            additionalModules: [translation, customModele, { autoPlaceSelectionBehavior: ['value', null] }],
        })

Your custom type doesn’t extend anything. Try adding "extends": [ "bpmn:FlowNode" ], to your extension so the properties will actually be added to every flow node (cf. this example).

I added inheritance for my main node, this improved the situation, now when copying a node, it has the label of the copied element, but the rest of the fields are not copied…

     {
            "name": "NodeProps",
            "extends": ["bpmn:FlowNode"],
            "properties": [
                {
                    "name": "inputsNumber",
                    "isAttr": true,
                    "type": "String"
                },

                {
                    "name": "modelType",
                    "isAttr": true,
                    "type": "String"
                },
                {
                    "name": "messageAppeal",
                    "isAttr": true,
                    "type": "String"
                },
....
}

I also tried to inherit from “bpmn:Task” but it also did not help

Without being able to see your whole implementation, I won’t be able to help you out further.

Are my values ​​stored correctly inside the element ? (this is a consumer item I’m evaluating)
image

where does the bottleneck cause this problem? How can I check each of them?

Can I somehow find out what is on my clipboard?

I managed to set up copying, but only for one of the nodes

{
            "name": "EndEventProps",
            "extends": ["bpmn:EndEvent"],
            "properties": [
                {
                    "name": "endVariant",
                    "isAttr": true,
                    "type": "String"
                },
                {
                    "name": "redirectSIP",
                    "isAttr": true,
                    "type": "String"
                }
            ]
        },

I found a significant difference inside the buisnessObject in the case of bpmn:EndEvent my data is stored directly inside the object, and in the case of bpmn:Task they are inside buisnessObject.$attr, I think this is the cause of the error, but I still don’t understand why this behavior occurs Understand.
on the first pick bpmn:Task
image
here is bpmn:EndEvent
image

No data should ever show up in $attrs. This is what happens when the property you’re setting is unknown. If you called your property messageAppeal you can’t set MessageAppeal. They are not the same. These are property names, not types like bpmn:Task which usually are uppercase.

yes, I think I understand what the error is, I tried to achieve uniform behavior through the prefix that I pass from the top level and made a case error, now I will try to fix it and report the result, thank you very much in advance!

that’s it! Thanks a million!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.