Adding a Flic button trigger to a Flow triggered by PowerApps

When building PowerApps, you can use Flow to perform a lot of actions that may be more complex than what you can or want to do directly within the PowerApp.  Flows are invoked via any a number of imperative properties of your PowerApp, such as

  • OnStart() - App
  • OnVisible(), OnHidden() - Screen
  • OnSelect() - Button, Text, Label, Drop down
  • OnCheck(), OnUncheck() - Checkbox
  • and more
When you connect a Flow to these controls' properties, then the Flow gets triggered when that action is performed.  For example, when you press a button or label, check or uncheck a Checkbox, or launch the PowerApp.  In essence, PowerApp itself provides the trigger to all these Flows.  

However, there are time, where you want something in PowerApp to occur when there is an external trigger.  For example, you want to update information in your PowerApp when a Flic IoT button is pressed.

The way this can be accomplished is using a Timer control in your App and a dual-trigger Flow.  Here's an example of how I built it..

Timer Control

The timer control, flicTimer, is responsible to do three things:
  1. Call the Flow
  2. Wait
  3. When completed, perform an action inside the App and restart
Here's a description of the property settings I've used:

Autostarttrueunless you need to manually invoke the listener Flow, start automatically
Duration12000make it long enough so that it wont time out, but not too short to cause multiple Flows to fire
OnTimerStartUpdateContext({clicked: GetFlicButton.Run().response});
If(clicked = "clicked", <do something>);
here's where you call the Flow and wait for a response. Once the Flow returned, I would perform a specific action
Repeattrueif the Flow didn't finish in time, repeat the timer


The Flow in this case is fairly simplistic.  It begins with the PowerApp triggering it.  Once triggered, the secondary trigger, When a Flic is pressed, is called to wait until the button is pressed.  There are two possible outcomes to this:
  1.  The button was pressed.  In that case, the branch on the right is executed and returns the "clicked" response to the PowerApp.
  2. The button was not pressed.  Here, the Flow will eventually time out and return an empty result to PowerApp.  

A similar logic can be applied to other types of triggers that may not be easily accessible within your PowerApp.

No comments:

Post a Comment

Employee Check-in Simplified using Power Automate

Company employees who move between offices are often faced with a tedious process of having to check-in at the security desk to get a tempor...