LowCodeGo logo

Power Apps – Environment Variable Basics

Overview

Environment Variables are essential for defining values that can be used across Power Platform tools such as Canvas Apps or Power Automate Flows. Values can also differentiate between environments ex) DEV, UAT and PROD. This provides flexibility, so you do not have to hardcode values for each environment, and instead query the Environment Variable table instead.

YouTube

Creating Environment Variables

To create an Environment Variable, it’s best to create in a solution allowing for easy promotion to other environments.

Go to New -> More -> Environment Variable

Create environment variable

Enter the following details

  • Display Name
  • Name (Schema Name) – populated based on Display Name. Modify if necessary
  • Description (Optional)
  • Data Type
    • Decimal Number
    • JSON
      • Structured data
    • Text
    • Yes/No
    • Data Source
      • Used for Connectors ex) SharePoint, Azure SQL
    • Secret
      • Azure Key Vault
  • Default Value
    • Fallback value if Current Value is not populated
  • Current Value
    • Always enter value here unless it’s unknown

Click Save

Retrieving Environment Variable in Canvas App

Go to Data on the left and add the following tables:

  • Environment Variable Definitions
  • Environment Variable Values
Search environment variables table

Use the Set function to assign the Environment Variable value. In this example, we are going to use App OnStart

Set(currentOrganization, LookUp(‘Environment Variable Values’, ‘Environment Variable Definition’.’Schema Name’ = “lcgco_Org”).Value);

Update OnStart property

At this point, you can use the variable as needed in the app.

Import Solutions with Environment Variables

If Importing a solution that contains an Environment Variable for the first time, it will bring over the Current Value. It’s recommended that you update the value right after import.

Any subsequent imports of the solution will not overwrite the updated Current Value.

Leave a Reply

Categories

Follow us

Copyright ©LowCodeGo 2025

Discover more from LowCodeGo

Subscribe now to keep reading and get access to the full archive.

Continue reading