PowerApps Tip Corner – Use Variables!

As any developer will tell you, variables are some of the most important objects when you are creating an application, and that holds true for PowerApps as well.  One thing I’ve learned about PowerApps (in particular when designing them), is that the more screens you have, the slower editing an App can be.  This is just one example of where a Global variable can help!

For example.  Let’s say I have 3 forms I want to add into a PowerApp.  My goal is to have a user access a particular form by pressing a button from the home screen.  By default, you may just create 4 different screens, 1 for Home, and 3 more to house each form.  But with a variable we can actually Hide or display each form on a single screen by setting it when the button is selected.

So, try this:  Create a ‘Home Screen’, then Create a ‘Forms’ screen.  On the Home Screen add 3 Buttons.  For my Example My form names will be Form1, Form2, and Form3.  On each Button’s OnSelect Property, set it to:

Set(formVar, “Form1vis”); Navigate(Forms, Cover)

Change Form1vis to Form2vis and Form3vis for each button.

Now on the Forms screen, add all three forms, and set the Visible Property for Form1 to the following:

Switch(formVar, “Form1vis”, true, false)

Repeat this for Form2 and Form3, replacing Form1vis with Form2vis, or Form3vis.

Now, Test out your App from the Home screen.  You will find that every time you click the button, the corresponding Form will be the only one displayed!

This is just one small example of how variables can be used to make your PowerApps more dynamic, and better performing.

Please check out some of my other articles to take a deeper dive into the product, and as always, please feel free to reach out to me at jo.karnes@centricconsulting.com

Leave a Reply