Environment variables are a great feature in the Power Platform offering. Let me shed some light on these variables with some W questions!
I could not better explain it than the official documentation, so I refer you happily to read it here. But as you might already think, the name is self explanatory.
Environment variables are quite handy when you are creating a flow in a development environment and this needs to be tested in another environment. The example in the How topic will cover the URL of an environment which differs from DEV, TEST and PROD.
An environment variable can be seen as an entity. You can add it to a solution and consume it as a normal entity within your flow. To do this, go to the desired solution in the appropriate environment.
Choosing this option will open a flyout with several options to create your environment variable. Please note the prefix of your publisher of the currently selected solution is used. There are currently 4 options of data type of your variable.
When you want to use the environment variable in a flow, you need to treat it as any other entity within CDS. So we will have to use the List Records action, since the Get Record action requires a fixed record ID. This would require adapting the flow when moving it to other environments, which bypasses the goal of an environment variable.
Environment variables consist of two different type of entities: environment variable definitions and environment variable values. You can already guess it, there is a relationship between those two. In our use case, we know the schema name of the environment variable, which is an attribute on the definition entity, but not on the value. However, we can do this within a single query instead of fetching the definition first and than, based on the definition id, fetching the value. Check out my other blog post to see how we use fetchXML to filter the records returned.
Because we used the fetchXML to filter, we are sure there is only one record returned. To avoid a loop and extra execution time, we use the compose function to get the property of the first element:
Do you have any other use cases for environment variables? Please let me know!