How to tell is flow was triggered by a Shortcut?

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

How to tell is flow was triggered by a Shortcut?

Post by Philip » 29 Nov 2017 08:51

I have a flow which has multiple triggers. Most of these are "when connected to <car> by bluetooth", but I also have a home screen Shortcut which can I use.

I want to do slightly different things within the flow depending on how it was triggered ("if it was car1, do this, but if it was car2, do something else") and that's easy.

What I can't figure out is how to determine if the flow was triggered by the Shortcut.

Is this possible, and if so how? (I could duplicate the flow, or possibly change the Shortcut to a Widget, but they both feel like rather inelegant solutions).

Many thanks.
--
Philip

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to tell is flow was triggered by a Shortcut?

Post by Desmanto » 29 Nov 2017 12:37

You can use expression after the trigger to check and branch the flow accordingly. Example, i have 11 time triggers at my office announcer flow. I split the branch by checking what is the name of the trigger, using condition expression. One of them is

Code: Select all

trigger == "Time: Sat 12:00"
To get the trigger name, just edit the trigger and copy the name from there. Remember to quote it at the expression.

Create several parallel expression to check the incoming trigger. You can check example in my index, flow sharing - navigation flow. I split the triggers using the same concept. For reason why parallel than series, check the "multiple choices" thread.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Re: How to tell is flow was triggered by a Shortcut?

Post by Philip » 29 Nov 2017 22:41

That worked - many thanks!
--
Philip

Post Reply