Canvas Apps
Understand Variables | How to use variable in Canvas App? – Power App

Understand Variables | How to use variable in Canvas App? – Power App

Variables are used to store information to be referenced and manipulated. In Canvas App we have three types of variables. Lets look into it..! 🙂

Types of variables:

TypeVariable ScopeDescription
Global variableAppYou can store (number, text string, Boolean, record, table, Etc.) value in this variable and access anywhere in your application.
Context variableScreenYou can store any value in this variable but you can make use of those variable only inside the screen. But you can pass this variable to different screen as a parameter value.
CollectionAppIt’s a complex type variable. Using this you can store Table, JSON, Etc. kind of values in this variable.

Variable Scope:

All the variable values are held in memory until application runs. Once application got closed all the values will be erased.

When your application opens all the variable values were blank.

Functions:

  1. For Global Variable
    • Use Set eg: Set(Name,”365Stack.in”);
  2. For Context Variable
    • Use UpdateContext eg: UpdateContext({Title:”365Stack.in”});
    • Use Navigate eg:Navigate(ScreenName,Title);
  3. For Collection
    • Use Collect, ClearCollect. Eg: Collect(EmpData,{Name:”365Stack”,Age:24}))

How to use it ?

Below screenshot will show some different way of using variables.

Set Variable On Button Select:

Using Variable In Textbox Default Property:

So once on button click value will be displayed in textbox. Refer above image for set variable.

Set Context Variable On Button Select:

Displaying Context Variable Using Label:

Load Collection On Button Select:

View Collection Data:

               From setting page you can view data available in the collection variables.

View Global And Context Variable:

Check walkthrough video :

YouTube player
0

Leave a Reply

Newsletter Signup

Subscribe to our weekly newsletter below and never miss out the latest updates

%d bloggers like this: