Msg.reset inside subflow not working on delay

Test Msg Cancel flow
...
[
{
"id": "5000652e2e0639f2",
"type": "subflow",
"name": "Cancel Delay Failure",
"info": "",
"category": "",
"in": [
{
"x": 180,
"y": 140,
"wires": [
{
"id": "93e904b826c5b927"
}
]
}
],
"out": ,
"env": ,
"meta": {},
"color": "#DDAA99"
},
{
"id": "ca1fc825888ca8ad",
"type": "subflow:93d1b74d61d4f90f",
"z": "5000652e2e0639f2",
"name": "",
"x": 520,
"y": 140,
"wires":
},
{
"id": "93e904b826c5b927",
"type": "change",
"z": "5000652e2e0639f2",
"name": "",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "true",
"tot": "bool"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 140,
"wires": [
[
"ca1fc825888ca8ad"
]
]
},
{
"id": "93d1b74d61d4f90f",
"type": "subflow",
"name": "TestMsgCancel",
"info": "",
"category": "",
"in": [
{
"x": 80,
"y": 100,
"wires": [
{
"id": "8e95cef841af3afe"
},
{
"id": "1b3f56701316f785"
}
]
}
],
"out": ,
"env": ,
"meta": {},
"color": "#DDAA99"
},
{
"id": "8e95cef841af3afe",
"type": "delay",
"z": "93d1b74d61d4f90f",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 280,
"y": 100,
"wires": [
[
"f8bc75fb8ecb0338"
]
]
},
{
"id": "f8bc75fb8ecb0338",
"type": "debug",
"z": "93d1b74d61d4f90f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": ""delay finished"",
"targetType": "jsonata",
"statusVal": "",
"statusType": "auto",
"x": 480,
"y": 100,
"wires":
},
{
"id": "1b3f56701316f785",
"type": "debug",
"z": "93d1b74d61d4f90f",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 270,
"y": 40,
"wires":
},
{
"id": "aa2a0675de682cbc",
"type": "tab",
"label": "Cancel Delay Works",
"disabled": false,
"info": "",
"env":
},
{
"id": "e8c53ad359599fe8",
"type": "inject",
"z": "aa2a0675de682cbc",
"name": "Set Delay",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 140,
"wires": [
[
"d04e986cf42f4425"
]
]
},
{
"id": "77bd611303adafee",
"type": "inject",
"z": "aa2a0675de682cbc",
"name": "Cancel Delay",
"props": [
{
"p": "reset",
"v": "true",
"vt": "bool"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 130,
"y": 180,
"wires": [
[
"d04e986cf42f4425"
]
]
},
{
"id": "d04e986cf42f4425",
"type": "subflow:93d1b74d61d4f90f",
"z": "aa2a0675de682cbc",
"name": "",
"x": 340,
"y": 140,
"wires":
},
{
"id": "3433a4566b875615",
"type": "comment",
"z": "aa2a0675de682cbc",
"name": "This works",
"info": "This works setting msg.reset=true from within a flow",
"x": 80,
"y": 80,
"wires":
},
{
"id": "1c1812546a3e8f75",
"type": "inject",
"z": "aa2a0675de682cbc",
"name": "Cancel Delay",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 320,
"wires": [
[
"e66ae0ac72899773"
]
]
},
{
"id": "78ab1eb439ec1abc",
"type": "comment",
"z": "aa2a0675de682cbc",
"name": "This fails",
"info": "This fails setting msg.reset=true from within a subflow",
"x": 80,
"y": 260,
"wires":
},
{
"id": "e66ae0ac72899773",
"type": "subflow:5000652e2e0639f2",
"z": "aa2a0675de682cbc",
"name": "",
"x": 350,
"y": 320,
"wires":
}
]
...

Cancel Delay Failure flow

[
    {
        "id": "5000652e2e0639f2",
        "type": "subflow",
        "name": "Cancel Delay Failure",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 180,
                "y": 140,
                "wires": [
                    {
                        "id": "93e904b826c5b927"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "ca1fc825888ca8ad",
        "type": "subflow:93d1b74d61d4f90f",
        "z": "5000652e2e0639f2",
        "name": "",
        "x": 520,
        "y": 140,
        "wires": []
    },
    {
        "id": "93e904b826c5b927",
        "type": "change",
        "z": "5000652e2e0639f2",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 140,
        "wires": [
            [
                "ca1fc825888ca8ad"
            ]
        ]
    },
    {
        "id": "93d1b74d61d4f90f",
        "type": "subflow",
        "name": "TestMsgCancel",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 80,
                "y": 100,
                "wires": [
                    {
                        "id": "8e95cef841af3afe"
                    },
                    {
                        "id": "1b3f56701316f785"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "8e95cef841af3afe",
        "type": "delay",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 280,
        "y": 100,
        "wires": [
            [
                "f8bc75fb8ecb0338"
            ]
        ]
    },
    {
        "id": "f8bc75fb8ecb0338",
        "type": "debug",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "\"delay finished\"",
        "targetType": "jsonata",
        "statusVal": "",
        "statusType": "auto",
        "x": 480,
        "y": 100,
        "wires": []
    },
    {
        "id": "1b3f56701316f785",
        "type": "debug",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 270,
        "y": 40,
        "wires": []
    },
    {
        "id": "aa2a0675de682cbc",
        "type": "tab",
        "label": "Cancel Delay Works",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e8c53ad359599fe8",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Set Delay",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 140,
        "wires": [
            [
                "d04e986cf42f4425"
            ]
        ]
    },
    {
        "id": "77bd611303adafee",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Cancel Delay",
        "props": [
            {
                "p": "reset",
                "v": "true",
                "vt": "bool"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 130,
        "y": 180,
        "wires": [
            [
                "d04e986cf42f4425"
            ]
        ]
    },
    {
        "id": "d04e986cf42f4425",
        "type": "subflow:93d1b74d61d4f90f",
        "z": "aa2a0675de682cbc",
        "name": "",
        "x": 340,
        "y": 140,
        "wires": []
    },
    {
        "id": "3433a4566b875615",
        "type": "comment",
        "z": "aa2a0675de682cbc",
        "name": "This works",
        "info": "This works setting msg.reset=true from within a flow",
        "x": 80,
        "y": 80,
        "wires": []
    },
    {
        "id": "1c1812546a3e8f75",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Cancel Delay",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 320,
        "wires": [
            [
                "e66ae0ac72899773"
            ]
        ]
    },
    {
        "id": "78ab1eb439ec1abc",
        "type": "comment",
        "z": "aa2a0675de682cbc",
        "name": "This fails",
        "info": "This fails setting msg.reset=true from within a subflow",
        "x": 80,
        "y": 260,
        "wires": []
    },
    {
        "id": "e66ae0ac72899773",
        "type": "subflow:5000652e2e0639f2",
        "z": "aa2a0675de682cbc",
        "name": "",
        "x": 350,
        "y": 320,
        "wires": []
    }
]

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506

Backtick (`) not single quote (') :sweat_smile:

Test Msg Cancel

[
    {
        "id": "5000652e2e0639f2",
        "type": "subflow",
        "name": "Cancel Delay Failure",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 180,
                "y": 140,
                "wires": [
                    {
                        "id": "93e904b826c5b927"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "ca1fc825888ca8ad",
        "type": "subflow:93d1b74d61d4f90f",
        "z": "5000652e2e0639f2",
        "name": "",
        "x": 520,
        "y": 140,
        "wires": []
    },
    {
        "id": "93e904b826c5b927",
        "type": "change",
        "z": "5000652e2e0639f2",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 140,
        "wires": [
            [
                "ca1fc825888ca8ad"
            ]
        ]
    },
    {
        "id": "93d1b74d61d4f90f",
        "type": "subflow",
        "name": "TestMsgCancel",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 80,
                "y": 100,
                "wires": [
                    {
                        "id": "8e95cef841af3afe"
                    },
                    {
                        "id": "1b3f56701316f785"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "8e95cef841af3afe",
        "type": "delay",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 280,
        "y": 100,
        "wires": [
            [
                "f8bc75fb8ecb0338"
            ]
        ]
    },
    {
        "id": "f8bc75fb8ecb0338",
        "type": "debug",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "\"delay finished\"",
        "targetType": "jsonata",
        "statusVal": "",
        "statusType": "auto",
        "x": 480,
        "y": 100,
        "wires": []
    },
    {
        "id": "1b3f56701316f785",
        "type": "debug",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 270,
        "y": 40,
        "wires": []
    },
    {
        "id": "aa2a0675de682cbc",
        "type": "tab",
        "label": "Cancel Delay Works",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e8c53ad359599fe8",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Set Delay",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 140,
        "wires": [
            [
                "d04e986cf42f4425"
            ]
        ]
    },
    {
        "id": "77bd611303adafee",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Cancel Delay",
        "props": [
            {
                "p": "reset",
                "v": "true",
                "vt": "bool"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 130,
        "y": 180,
        "wires": [
            [
                "d04e986cf42f4425"
            ]
        ]
    },
    {
        "id": "d04e986cf42f4425",
        "type": "subflow:93d1b74d61d4f90f",
        "z": "aa2a0675de682cbc",
        "name": "",
        "x": 340,
        "y": 140,
        "wires": []
    },
    {
        "id": "3433a4566b875615",
        "type": "comment",
        "z": "aa2a0675de682cbc",
        "name": "This works",
        "info": "This works setting msg.reset=true from within a flow",
        "x": 80,
        "y": 80,
        "wires": []
    },
    {
        "id": "1c1812546a3e8f75",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Cancel Delay",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 320,
        "wires": [
            [
                "e66ae0ac72899773"
            ]
        ]
    },
    {
        "id": "78ab1eb439ec1abc",
        "type": "comment",
        "z": "aa2a0675de682cbc",
        "name": "This fails",
        "info": "This fails setting msg.reset=true from within a subflow",
        "x": 80,
        "y": 260,
        "wires": []
    },
    {
        "id": "e66ae0ac72899773",
        "type": "subflow:5000652e2e0639f2",
        "z": "aa2a0675de682cbc",
        "name": "",
        "x": 350,
        "y": 320,
        "wires": []
    }
]

Cancel Delay Failure

[
    {
        "id": "5000652e2e0639f2",
        "type": "subflow",
        "name": "Cancel Delay Failure",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 180,
                "y": 140,
                "wires": [
                    {
                        "id": "93e904b826c5b927"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "ca1fc825888ca8ad",
        "type": "subflow:93d1b74d61d4f90f",
        "z": "5000652e2e0639f2",
        "name": "",
        "x": 520,
        "y": 140,
        "wires": []
    },
    {
        "id": "93e904b826c5b927",
        "type": "change",
        "z": "5000652e2e0639f2",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 140,
        "wires": [
            [
                "ca1fc825888ca8ad"
            ]
        ]
    },
    {
        "id": "93d1b74d61d4f90f",
        "type": "subflow",
        "name": "TestMsgCancel",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 80,
                "y": 100,
                "wires": [
                    {
                        "id": "8e95cef841af3afe"
                    },
                    {
                        "id": "1b3f56701316f785"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "8e95cef841af3afe",
        "type": "delay",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 280,
        "y": 100,
        "wires": [
            [
                "f8bc75fb8ecb0338"
            ]
        ]
    },
    {
        "id": "f8bc75fb8ecb0338",
        "type": "debug",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "\"delay finished\"",
        "targetType": "jsonata",
        "statusVal": "",
        "statusType": "auto",
        "x": 480,
        "y": 100,
        "wires": []
    },
    {
        "id": "1b3f56701316f785",
        "type": "debug",
        "z": "93d1b74d61d4f90f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 270,
        "y": 40,
        "wires": []
    },
    {
        "id": "aa2a0675de682cbc",
        "type": "tab",
        "label": "Cancel Delay Works",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e8c53ad359599fe8",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Set Delay",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 140,
        "wires": [
            [
                "d04e986cf42f4425"
            ]
        ]
    },
    {
        "id": "77bd611303adafee",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Cancel Delay",
        "props": [
            {
                "p": "reset",
                "v": "true",
                "vt": "bool"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 130,
        "y": 180,
        "wires": [
            [
                "d04e986cf42f4425"
            ]
        ]
    },
    {
        "id": "d04e986cf42f4425",
        "type": "subflow:93d1b74d61d4f90f",
        "z": "aa2a0675de682cbc",
        "name": "",
        "x": 340,
        "y": 140,
        "wires": []
    },
    {
        "id": "3433a4566b875615",
        "type": "comment",
        "z": "aa2a0675de682cbc",
        "name": "This works",
        "info": "This works setting msg.reset=true from within a flow",
        "x": 80,
        "y": 80,
        "wires": []
    },
    {
        "id": "1c1812546a3e8f75",
        "type": "inject",
        "z": "aa2a0675de682cbc",
        "name": "Cancel Delay",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 320,
        "wires": [
            [
                "e66ae0ac72899773"
            ]
        ]
    },
    {
        "id": "78ab1eb439ec1abc",
        "type": "comment",
        "z": "aa2a0675de682cbc",
        "name": "This fails",
        "info": "This fails setting msg.reset=true from within a subflow",
        "x": 80,
        "y": 260,
        "wires": []
    },
    {
        "id": "e66ae0ac72899773",
        "type": "subflow:5000652e2e0639f2",
        "z": "aa2a0675de682cbc",
        "name": "",
        "x": 350,
        "y": 320,
        "wires": []
    }
]

Ok,

I see the problem.
A subflow is not a singleton

every subflow that is deployed is a new instance of the subflow.

Therefore Cancel Delay Failure fires up its own instance of TestMsgCancel

think of a subflow as a blueprint - not a single instance of something

If you press the set delay inject you'll see the delay is executed then the msg appears.
If you press the set delay under This Works then press the cancel delay you'll see the test subflow is invoked but the delay is cancelled and the msg after the delay does not appear.
If you press the set delay then the Cancel Delay under the This Fails you'll see the test subflow is invoked, the delay is executed, i.e., not cancelled, and the msg after the delay is executed

If you look inside the Cancel Delay Failure it sends the msg with reset=true to the TestMsgCancel subflow

So does that mean a delay initiated in any subflow can never be cancelled?

So does that mean a delay initiated in any subflow can never be cancelled?

If you wish to void a delay that is inside a subflow - then you must send the reset property to that (instance) of the subflow (or more accurately the delay node that is inside that subflow instance)

This is why your first one works - you are addressing the same subflow instance.

Each subflow has its own context - it does not share the context of its self globally

If you look inside the Cancel Delay Failure it sends the msg with reset=true to the TestMsgCancel subflow

Yes - but it is its own copy (or instance) of TestMsgCancel Therefore is not making any difference to the instance of TestMsgCancel that is in your main flow.

Like I said here

A subflow is not a singleton - every copy of your subflow In your main flow, has its own context and environment

If you do want something like a singleton then maybe the link-call node and return is an option .

1 Like

What is the best approach to doing this? Saving the original msg that invoked the subglow with the delay into a global var so it can be sent again to that same subflow with the reset=true? Does that send the msg to the same instance of that subflow?

If there is no easy way to do this I can always just use a global flag to tell the delayshutoff subflow whether to actually do the shut off.

You could use link-call nodes as suggested. That way there is only 1 set of nodes being operated on.

I don't understand what you mean by that. Each instance of the subflow is a node that appears in a flow in the editor. To send a message to a particular instance, that message needs to be sent down a wire into the node.

I have two flows A and B that both call subflow X. A calls subflow X to do a certain function that entails a delay node that delays 90 minutes. Flow B needs to cancel the delay in subflow X. My understanding is the reason it didn't work the way I first tried it was there are two instances of subflow X - X(A) and X(B). The delay has subflow X(A) stopped waiting for the delay to expire. When flow B tried to cancel it by calling subflow X it was actually sending the msg with reset=true to instance X(B) thus not cancelling the delay in X(A).

So the question was if I saved the message from within X(A) in a global var and then send it to a different instance of X does that actually send the message back to X(A)?

I think part of your problem may be that you have the wrong mental image of subflows. Don't think of it as something you call (any more than you call a Change node). When you place an instance of the subflow on a flow it is conceptually like placing a copy of all the nodes in the subflow on the page in a little box. Each flow where you place the subflow gets its own copy of the internal nodes. So when you pass a message to your subflow in flow A it goes through the subflow nodes that are in that flow, and when you do it in flow B the message goes through a different copy of the nodes. It isn't actually quite like that in the implementaion, but conceptually that is what happens. The only way you can cancel the delay in X(A) is by sending a message to the node in that copy of the subflow, you cannot do it by passing a message into the copy of the nodes in flow B. You could achieve it by using global context to pass messages between the subflows, but that would be a hack which would probably bite you at some stage in the future.

Did you investigate the possibility of using Link Call nodes rather than subflows as suggested earlier? It sounds as if that may better match your mental image of what you want to do.

I just finished setting up a test of what I'm trying to do using link call and after adding the catch for the timeout I think it is going to work correctly. Fortunately in both the flows that would use the link call there is no further action needed after the link call so it looks like just catching the timeout is sufficient.

Thanks everyone for all the help.

1 Like

Excellent!

The thing to remember here, is that a subflow is geared to be more a 'reusable' logic block.
2 copies of your subflow in your main flow, do not share context - each has its own.

Personally, I think subflows are slightly mis-labelled.
I tend to think of them as 'blueprints' or as above, 'reusable' logic blocks.

In my second test I found a gotcha - all my "actions" are done as subflows and there are a lot of them. LinkCalls do not work from subflows only flows. Converting all my "action" subflows into flows and changing all the "calls" to LinkCalls would be way more work than just adding a global flag to tell the DelayedShutdown subflow to not actually do anything when its delay is finished.

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