PowerApps Pro Tips | Using Variables

By March 3, 2017PowerApps, Pro Tips

Like parameters, variables are very helpful, and can be used to increase user communication in your app. A variable in Microsoft PowerApps is used with the function UpdateContext. Below are a few ways you can start using variables immediately in your apps.

User Communication

In a scenario where you’re sending data back to a source and doing a Patch, at times the user can be confused about what’s happening (if anything is going on at all).  You might not want to take a user back to another page until the Patch is complete. To more effectively communicate to the user what is happening, try the following:

  1. Create a new app.
  2. Add a data source.
  3. Add a button that will send a record back to a source.
  4. Add the following code before your patch runs: UpdateContext({MyVariable:”Sending Data”});
  5. Add the following code after your patch runs: UpdateContext({MyVariable:” “})
  6. Update the Button Text to: If(MyVariable = “Sending Data”,MyVariable,”Send”)

Now your user will see the button change text to let them know what is happening.

Sending Data from Page to Page

There may be times when you want the user to interact with data on Screen 1, then pass some information to Screen 2 based on an interaction on the first screen. This becomes useful when you have a list of items on the first screen, and you want to show details on the second screen. To try this out, use the following steps:

  1. Create a new app.
  2. Add two screens.
  3. On the first screen, add a drop down.
  4. The OnChange property needs this: Navigate(Screen2,Fade,{MyVariable:Dropdown1.Selected.Value})
  5. On the second screen, add a text box.
  6. Set the text property to: MyVariable

Now you can pass variables from page to page. Variables will only live on that page that you are on. If you need global variables, then you can use a collection.

Need PowerApps Training?

Choose Your Plan