Introduction Of PowerApps And Variables In PowerApps

What is PowerApps

  1. PowerApps is the platform/service provided by Microsoft.
  2. We can use PowerApps to build business apps by using low code, no code technology that runs on browsers, mobile, or tablets.

Usage

  1. If we are working with one or more database, then PowerApps quickly integrate more than one database to one place
  2. To build quick application that will be used for specific purpose

What are the different types of PowerApps

  1. Canvas App
  2. Model Driven App
  3. Portal Apps

Canvas App

  1. In canvas app we can drag and drop controls to the screens and create meaningful design by placing various controls at proper place on the screen
  2. When your design part completes you can add different database to the application and assign the controls to the database fields
  3. We can connect more than 200 data sources to the application
  4. You can go with canvas app if your application is Design oriented
  5. Canvas App takes design first approach
  6. Canvas app is not responsive by default, we must use containers and different controls to make it responsive

Model Driven App

  1. Model driven app takes data first approach
  2. You can use model driven app where there is complex business logic like tables are internally connected to each other
  3. We can use CDS(Common Data Source)/Dataverse as a database
  4. This application is responsive by default
  5. Ex-Library Application

Portal App

  1. Portal App allows user to create website and share it with organization and outside
  2. It allows customizing pages

Variables in PowerApps

We can use variable to hold the data temporarily

Local Variable

  1. Scope of variable – within the screen
  2. Syntax – UpdateContext ({ varlocal : ”demovariable”)

Example

1. Create the UI as shown below controls and, in the screenshot,

  1. txt_FirstNum – Textbox Control to Enter First Number
  2. txt_SecondNum – Textbox Control to Enter Second Number
  3. lbl_locfirst – Label Control to show variable locFirst
  4. lbl_locsecond – Label Control to show variable Second
  5. btnResult - Button Control to calculate the result on select of this button
  6. lbl_result – Label Control to Show Result variable locTotal

Basic PowerApp Design

 2. Set the variable locFirst of OnChange property of Textbox - txt_FirstNum

 UpdateContext({locFirst:txt_FirstNum.Text})

2 Onchange_FirstNum

3. Set the variable locSecond of OnChange property of Textbox - txt_SecondNum

UpdateContext({locSecond:txt_SecondNum.Text})

Introduction Of PowerApps And Variables In PowerApps

4. Change the Text property of “lbl_locfirst” control to variable “locFirst” as shown below

Introduction Of PowerApps And Variables In PowerApps

5. Change the Text property of “lbl_locSecond” control to variable “locSecond” as shown below

Introduction Of PowerApps And Variables In PowerApps

6. Now Declare one more local variable “locTotal” on “OnSelect” property of button “btnResult” and assign result of “locFirst + locSecond” as shown below

Introduction Of PowerApps And Variables In PowerApps

7. Change the “Text” property of “lblResult” to show variable locTotal as a result as shown below

Introduction Of PowerApps And Variables In PowerApps

8. By running the app result will look like this once user enter First Number and Second Number and After clicking on Result Button

Introduction Of PowerApps And Variables In PowerApps

Great.........! you learned how to set and use the local variable with Example

Let's learn how global variable works.

2. Global Variable

 Scope of variable – Throughout the application and in all screens

 Syntax – Set(glbvar, “TestValue”)

Example – In above example we used local variable “locResult” and shown in same screen but if we decide to show result is another screen it will show the below error.

“Name isn’t valid. ‘locTotal’ isn’t recognized.”

Introduction Of PowerApps And Variables In PowerApps

To overcome this issue we can use global variable on “OnSelect” property of “btnResult” which we created earlier.

Introduction Of PowerApps And Variables In PowerApps

And you will see the result on other screen by using globalvariable “locTotal” as shown below

Introduction Of PowerApps And Variables In PowerApps

Yuuupppppp....Now you are ready to apply logic to your project

Happy Coding............:)


Similar Articles