Environment variables in Solution

An environment variable would let us establish a default value and then override it in each environment where the flow is deployed to. We can add an existing environment variable in a solution or create a new one that automatically becomes part of that solution.

Environment variables
Previously, it was a common practice for all stored data to be available in a single environment only. Now, thanks to environment variables, you have the flexibility to transport your configuration data from one environment to another within the same tenant. After creating environment variables in Dataverse for apps, we can consume them by retrieving data from the Environment Variable Definition and Environment Variable Value entities.

In this exercise, we will create an environment variable for the sharepoint site and sharepoint list and use that in the power automate flow.

Create an environment variable In this task, we will create an environment variable.
Step 1: Sign in to Power Apps with the organizational account. Select Solutions and select the solution in which we want to create the environment variables.
Step 2: Select + New > More > Environment variable.

Environment variables in Solution

Step 3: The New environment variable pane is open at the right.

Environment variables in Solution

a) Display name: Enter a name for the environment variable.
b) Name: The unique name is automatically generated from the Display name, but we can change it.
c) Data Type: Select from Decimal number, Text, JSON, Two options, Data source, or Secret.

Let’s give the Display name to Var Sharepoint site.
Let’s give the Name to VarSharepointsite.
In the Description field let’s write “This is the url of the sharepoint site”.
In the Data Type select Data source.
In the Connector select SharePoint.

Environment variables in Solution

d) Current Value: Also known as the value. This property is optional and is a part of the Environment Variable Value table (internal name is environmentvariablevalue). When a value is present it will be used, even if a default value is also present.

Environment variables in Solution

e) Default Value: This column is part of the Environment Variable Definition table (internal name is environmentvariabledefinition), and is not required. The default value is used if there's no current value.

Environment variables in Solution

Step 4: Click on the + New site value in the Current site value section. And then select the sharepoint site. And then select Save to save the changes.

Environment variables in Solution

The environment variable is created in the solution.

Step 5: Let’s create another Environment variable.
Let’s write the Display name to Var Sharepoint List.
Let’s write the Name to VarSharepointList.
Let’s write the Data Type to Data source.

Environment variables in Solution

From the Current list select the list that we want.

Environment variables in Solution

Click on Save to save the changes.

Edit the flow

In this task, we will edit the flow to use the environment site and list variables.
Step 1: From the solution, open the Sharepoint-selected item cloud flow that we added to the solution.
Step 2: Select Edit.

Environment variables in Solution

Step 3: Expand the “For a selected item” step.
Step 4: Select the “Site Address” and the “List Name” field, and select Var Sharepoint site and Var Sharepoint List, variables from the Dynamic content pane.

Environment variables in Solution

Export and Import Solution

Before exporting the solution, open the environment variables and select the ellipsis (...) button next to current value and then select Remove from this solution. We are removing the current value from the solution because we want other people who use this solution to provide their values.

Environment variables in Solution

When we import the solution in the other environment and if environment variables are in the solution that don't have a value, it shows us the popup to specify the Current values for environment variables for the current environment in which it is imported.

Environment variables in Solution