Delete Context by passing variable to change node

Hi,

In the change node, is it possible to delete a context data using variable rather than static value?

[
    {
        "id": "cf68980c75bbdff2",
        "type": "inject",
        "z": "9a41062e6cbfa995",
        "name": "Create a flow",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 510,
        "y": 1200,
        "wires": [
            [
                "aca3e88d0677b22b"
            ]
        ]
    },
    {
        "id": "5e2cbe5acd1dae3f",
        "type": "inject",
        "z": "9a41062e6cbfa995",
        "name": "Delete flow",
        "props": [
            {
                "p": "delete",
                "v": "test",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 510,
        "y": 1280,
        "wires": [
            [
                "8ed33e521ab0c2cd"
            ]
        ]
    },
    {
        "id": "aca3e88d0677b22b",
        "type": "change",
        "z": "9a41062e6cbfa995",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "test",
                "pt": "flow",
                "to": "1234",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 1200,
        "wires": [
            []
        ]
    },
    {
        "id": "8ed33e521ab0c2cd",
        "type": "change",
        "z": "9a41062e6cbfa995",
        "name": "",
        "rules": [
            {
                "t": "delete",
                "p": "{{delete}}",
                "pt": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 700,
        "y": 1280,
        "wires": [
            []
        ]
    }
]

Yes and no, yes if the flow variable is a property of a flow variable, flow.foo.bar , you could delete bar.
To delete foo i think you need a function
e.g.

[{"id":"255b37b181e70dfc","type":"inject","z":"30af2d3e.d94ea2","name":"Create a flow","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":2160,"wires":[["9d29a49cb4715fa7"]]},{"id":"9d29a49cb4715fa7","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"test","pt":"flow","to":"1234","tot":"str"},{"t":"set","p":"nested.test","pt":"flow","to":"5678","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":2160,"wires":[[]]},{"id":"a6d109253ec5d58e","type":"inject","z":"30af2d3e.d94ea2","name":"Delete flow","props":[{"p":"delete","v":"test","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":320,"y":2220,"wires":[["1d795d52.7eebab"]]},{"id":"290d1105.bfa1ce","type":"inject","z":"30af2d3e.d94ea2","name":"nested property delete","props":[{"p":"delete","v":"test","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":390,"y":2280,"wires":[["59e935db.ca3bcc"]]},{"id":"59e935db.ca3bcc","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"delete","p":"nested[msg.delete]","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":2280,"wires":[[]]},{"id":"1d795d52.7eebab","type":"function","z":"30af2d3e.d94ea2","name":"","func":"flow.set(msg.delete, undefined);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":2220,"wires":[[]]}]

thanks :slightly_smiling_face: the nested method works for me

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