Difference between revisions of "Environment Variables"

From Power Wiki
Jump to navigation Jump to search
Line 1: Line 1:
TBD
+
Environment Variables (EnvVars) can be used to retrieve a value based on the current environment.
  
[[How to set Environment Variables value]]
+
== General ==
 +
Environment Variables can return a value based on the environment the requesting application is in.
 +
EnvVars are solution aware and can therefore be "transported" with a usual Deployment (see [[ALM]]]).
 +
 
 +
{{
 +
PWBoxInfo
 +
| title = Be aware
 +
| text = Local values should not be included in a solution. Otherwise, it will be impossible to override the value in a downstream environment.
 +
}}
 +
 
 +
=== Structure ===
 +
EnvVars are built with two tables:
 +
* Environment Variable Definition
 +
* Environment Variable Value
 +
 
 +
==== Environment Variable Definition ====
 +
As the name suggests posts in this table contain the definition of an environment variable. This contains
 +
* DiplayName
 +
* SchemaName
 +
* Description
 +
* Data Type
 +
* Default Value
 +
 
 +
==== Environment Variable Value ====
 +
Also called "Local Value". A post in this table is always related to some definition and should never be included in a solution.
 +
It overrides the default value of a definition and is the value of the current environment.
 +
 
 +
=== Use case ===
 +
Use cases could for example be
 +
* URL's
 +
* Canvas App Ids
 +
* Record Ids
 +
* Switches
 +
* Connections
 +
* Other Configuration
 +
 
 +
=== How to create ===
 +
Environment Variables are, as mentioned, Solution components and should be created from a solution as well.
 +
First, the definition has to be created. After you save the first time you can add a local value. This local value should then be removed from the solution (via the ... besides it).
 +
 
 +
=== How to use ===
 +
Power Automate has a native integration with EnvVars. All the available EnvVars will be shown in the list of dynamic values.
 +
{{
 +
PWBoxInfo
 +
| title = Be aware
 +
| text = If you use this approach EnvVars are cached. When you change the value you have to turn all the flows off and on to get the new value.
 +
}}
 +
 
 +
If you would like to use EnvVars in any other way (Plugins, JS, ...) you have to handle them yourself. This means getting the rows and deciding whether to use the default or local value.
 +
 
 +
== History ==
 +
* 2019-11-04 - Announcing public Preview ([https://powerapps.microsoft.com/en-us/blog/environment-variables-available-in-preview/ link to MS announcement])
 +
* 2020-09-15 - Announcing GA and new Solution import experience ([https://powerapps.microsoft.com/en-us/blog/announcing-the-new-solution-import-experience-with-connections-and-environment-variables/ link to MS announcement])
 +
* 2021-04-14 - Announcing Type Data Source ([https://powerapps.microsoft.com/en-us/blog/announcing-data-source-environment-variables/ link to MS announcement])
 +
* 2021-08-19 - Announcing public Preview of Environment Variables Support in Power Platform Build Tools ([https://powerapps.microsoft.com/en-us/blog/announcing-the-public-preview-for-connection-references-support-in-power-platforms-tools/ link to MS announcement])
 +
* 2021-12-15 - Announcing GA of Environment Variables Support in Power Platform Build Tools ([https://powerapps.microsoft.com/en-us/blog/power-platform-developer-tools-november-refresh/ link to MS announcement])
 +
 
 +
== Related Content ==
 +
=== PowerWiki ===
 +
* [[How to set Environment Variables value]]
 +
* [[Model-driven apps Settings]]
 +
 
 +
=== Microsoft Resources ===
 +
* [https://docs.microsoft.com/en-us/powerapps/maker/data-platform/environmentvariables Use Environment Variables]
 +
* [docs.microsoft.com/en-us/power-platform/alm/devops-build-tool-tasks#power-platform-import-solution Import Solution Task] of Power Platform Build Tools
 +
 
 +
=== Community Content ===
 +
* [https://sharepains.com/2021/05/26/environment-variables-in-power-automate/ Environment Variables in Power Automate] by Pieter Veenstra
 +
* [https://iiu.dk/2021/05/12/power-platform-environment-variables/ Now it is time to be Curious about Power Platform Environment Variables!] by Jens Kofod
 +
* [https://www.powerplatformunicorn.com/2021/08/30/power-platform-data-source-environment-variables/ Power Platform Data Source Environment Variables] by Rebekka Aalbers
 +
* [https://www.inogic.com/blog/2021/02/using-environment-variables-in-dynamics-365-crm-part-1/ Using Environment Variables in Dynamics 365 CRM – Part 1] by Inogic
 +
* [https://crmtipoftheday.com/1363/get-environment-variables-in-power-automate-and-power-apps/ Tip #1363: Get Environment Variables in Power Automate (and Power Apps)] by CRM Tip of the Day
 +
* [github.com/drivardxrm/Dataverse-CustomApis Dataverse CustomAPIs to get EnvVar Value] by David Rivard

Revision as of 14:33, 19 December 2021

Environment Variables (EnvVars) can be used to retrieve a value based on the current environment.

General

Environment Variables can return a value based on the environment the requesting application is in. EnvVars are solution aware and can therefore be "transported" with a usual Deployment (see ALM]).

Be aware

Local values should not be included in a solution. Otherwise, it will be impossible to override the value in a downstream environment.

Structure

EnvVars are built with two tables:

  • Environment Variable Definition
  • Environment Variable Value

Environment Variable Definition

As the name suggests posts in this table contain the definition of an environment variable. This contains

  • DiplayName
  • SchemaName
  • Description
  • Data Type
  • Default Value

Environment Variable Value

Also called "Local Value". A post in this table is always related to some definition and should never be included in a solution. It overrides the default value of a definition and is the value of the current environment.

Use case

Use cases could for example be

  • URL's
  • Canvas App Ids
  • Record Ids
  • Switches
  • Connections
  • Other Configuration

How to create

Environment Variables are, as mentioned, Solution components and should be created from a solution as well. First, the definition has to be created. After you save the first time you can add a local value. This local value should then be removed from the solution (via the ... besides it).

How to use

Power Automate has a native integration with EnvVars. All the available EnvVars will be shown in the list of dynamic values.

Be aware

If you use this approach EnvVars are cached. When you change the value you have to turn all the flows off and on to get the new value.

If you would like to use EnvVars in any other way (Plugins, JS, ...) you have to handle them yourself. This means getting the rows and deciding whether to use the default or local value.

History

Related Content

PowerWiki

Microsoft Resources

  • Use Environment Variables
  • [docs.microsoft.com/en-us/power-platform/alm/devops-build-tool-tasks#power-platform-import-solution Import Solution Task] of Power Platform Build Tools

Community Content