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

%d bloggers like this: