Calling a flow with arguments/parameters
Moderator: Martin
-
- Posts: 69
- Joined: 14 Feb 2019 15:04
Calling a flow with arguments/parameters
I think this would fundamentally change the way we build our flows: transforming the flow concept into a function, with multi-threading support.
We can already pass to the calling flow some variables, but what about calling a flow with multiple parameters, which can be used to assign values to variables inside the called flow?
Of course, for this to be complete, the "execute flows" needs to be extended (with UI that adds parameters) and a script function would tremendously help as well.
This way, we can easily repeat complex actions (performed by the called flow itself), building complex "functions", without using multiple global variables, while also allowing parallel executions (because using a single global variable in both calling/executing flow, in the case of multithreading, doesn't work of course).
We can already pass to the calling flow some variables, but what about calling a flow with multiple parameters, which can be used to assign values to variables inside the called flow?
Of course, for this to be complete, the "execute flows" needs to be extended (with UI that adds parameters) and a script function would tremendously help as well.
This way, we can easily repeat complex actions (performed by the called flow itself), building complex "functions", without using multiple global variables, while also allowing parallel executions (because using a single global variable in both calling/executing flow, in the case of multithreading, doesn't work of course).
Re: Calling a flow with arguments/parameters
Its already supported. When action "Execute flows" runs it send all variables of parent flow to child flow.
The executed flow will inherit the execution context with all variables of the parent flow.
The variables usually supplied by the trigger of the target flow will not be available since the trigger of the target flow is bypassed when using this action.
-
- Posts: 69
- Joined: 14 Feb 2019 15:04
Re: Calling a flow with arguments/parameters
And how do you stop a particular running instance of a flow, if the flow is called from multiple places? How do you identify the flow's thread so you can act on it, without parameters which you can control, such as an ID, in paralel executions?
So you see, it's not the same thing.
So you see, it's not the same thing.
Re: Calling a flow with arguments/parameters
Automagic has Flow execution policy for that viewtopic.php?f=3&t=6985
-
- Posts: 69
- Joined: 14 Feb 2019 15:04
Re: Calling a flow with arguments/parameters
Yes, I know, but it's still not the same thing
You have absolutely 0 control on a particular running instance of a flow, if that flow is called from multiple places (other flows). For example, I want to stop an instance of "Flow X" initially called by "Flow A", but from "Flow B", in the middle of its execution, without running another instance, in the same time not acting on the instance of "Flow X" called by "Flow C".
You can refer (identify) the running instance by assigning/passing it some parameters, like ID (which you can control - because you can't dynamically somehow create a copy of a flow and rename that flow, to execute it). Or pass other parameters, like you do with functions, without automatically copying the entire context of the calling flow, because it's also lighter on the memory.
You have absolutely 0 control on a particular running instance of a flow, if that flow is called from multiple places (other flows). For example, I want to stop an instance of "Flow X" initially called by "Flow A", but from "Flow B", in the middle of its execution, without running another instance, in the same time not acting on the instance of "Flow X" called by "Flow C".
You can refer (identify) the running instance by assigning/passing it some parameters, like ID (which you can control - because you can't dynamically somehow create a copy of a flow and rename that flow, to execute it). Or pass other parameters, like you do with functions, without automatically copying the entire context of the calling flow, because it's also lighter on the memory.
Re: Calling a flow with arguments/parameters
If i am not wrong you want to say that suppose Flow A and Flow C started instance of Flow X at same time. Now you want to stop Flow X started by Flow A using Flow B.
If thats correct then it's still possible to stop that particular instance using Global Variable and triggername.
If thats correct then it's still possible to stop that particular instance using Global Variable and triggername.
-
- Posts: 69
- Joined: 14 Feb 2019 15:04
Re: Calling a flow with arguments/parameters
Hmm, i do not know about triggername.
Many thanks, I'll look into it.
Many thanks, I'll look into it.
Re: Calling a flow with arguments/parameters
sorry its called "flow_name".elektroinside wrote:Hmm, i do not know about triggername.
Many thanks, I'll look into it.
When a flow is executed there is three variables always present - flow_name, trigger, triggertime
-
- Posts: 69
- Joined: 14 Feb 2019 15:04
Re: Calling a flow with arguments/parameters
Hmm, I'm unable to find flow_name in the documentation, only "imported_flow_name".anuraag wrote:sorry its called "flow_name".elektroinside wrote:Hmm, i do not know about triggername.
Many thanks, I'll look into it.
When a flow is executed there is three variables always present - flow_name, trigger, triggertime
Re: Calling a flow with arguments/parameters
It's not contain in documentation. You can check it by creating a new flow. Assign trigger or leave it blank. Next attach debug dialog. Run it.
Here flow_name won't help as it changes when child flow is executed. You need to assign a variable before executing another flow or may be variable trigger can be used.
Here flow_name won't help as it changes when child flow is executed. You need to assign a variable before executing another flow or may be variable trigger can be used.