Calling a flow with arguments/parameters

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

elektroinside
Posts: 69
Joined: 14 Feb 2019 15:04

Calling a flow with arguments/parameters

Post by elektroinside » 07 Mar 2019 08:45

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).

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Calling a flow with arguments/parameters

Post by anuraag » 07 Mar 2019 09:51

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.

elektroinside
Posts: 69
Joined: 14 Feb 2019 15:04

Re: Calling a flow with arguments/parameters

Post by elektroinside » 07 Mar 2019 10:47

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.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Calling a flow with arguments/parameters

Post by anuraag » 07 Mar 2019 10:57

Automagic has Flow execution policy for that viewtopic.php?f=3&t=6985

elektroinside
Posts: 69
Joined: 14 Feb 2019 15:04

Re: Calling a flow with arguments/parameters

Post by elektroinside » 07 Mar 2019 11:21

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.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Calling a flow with arguments/parameters

Post by anuraag » 07 Mar 2019 11:42

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.

elektroinside
Posts: 69
Joined: 14 Feb 2019 15:04

Re: Calling a flow with arguments/parameters

Post by elektroinside » 07 Mar 2019 11:56

Hmm, i do not know about triggername.

Many thanks, I'll look into it.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Calling a flow with arguments/parameters

Post by anuraag » 07 Mar 2019 12:01

elektroinside wrote:Hmm, i do not know about triggername.

Many thanks, I'll look into it.
sorry its called "flow_name".

When a flow is executed there is three variables always present - flow_name, trigger, triggertime

elektroinside
Posts: 69
Joined: 14 Feb 2019 15:04

Re: Calling a flow with arguments/parameters

Post by elektroinside » 07 Mar 2019 12:22

anuraag wrote:
elektroinside wrote:Hmm, i do not know about triggername.

Many thanks, I'll look into it.
sorry its called "flow_name".

When a flow is executed there is three variables always present - flow_name, trigger, triggertime
Hmm, I'm unable to find flow_name in the documentation, only "imported_flow_name".

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Calling a flow with arguments/parameters

Post by anuraag » 07 Mar 2019 12:42

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.

Locked