Power Automate – Environment Variables
Background –
Hello Everyone,
Today I am going to introduce to you about Environment Variables in Power Automate
We can use the site variable and list variable as site address and list name.When we import and export the Power Automate we have to change only connection and environment variable. While export the Power Automate i am facing some issue related to connection in other tenant
Background:
- We have Power Automate and having action – GetItems
- In this action we have specified site URL and List URL
- Since we are implementing this Power Automate in our local environment we have specified local Site URL and List names selected
- So till now everything is fine but as we exported Power Automate from local environment and importing to customer tenant we were facing an issue
- Importing is not successful , we have workaround there which we discussed in last article – https://knowledge-junction.in/2022/04/05/power-platform-importing-power-automate-from-one-tenant-to-another-tenant-resolving-error-flow-save-failed-with-code-multipleerrorsoccurred-and-message-the-dynamic-operation-request-to-api/
- But best practice is to use Environment Variables, so lets discuss
What are environment variable ?
- Environment variable store the parameter keys, values which then serve as input to various other application objects. Separating the parameters from the consuming objects allow us to change the values within the same environment or when we migrate solutions to other environment.
- Store configuration for the data source used in canvas app and flows. SharePoint Online site and list parameters can be stored as environment variables. Allowing us to connect to different sites and lists in different environment without needing to modify the apps and flows.
Advantage of environment variable –
If we need to retire a data source in production we can simply update the environment variable with new information for the new data source the app and flow do not require modification and will start using the new data source.
How to create environment variable –
Step 1:
Sign in to power automate and on left pane select solutions.

Step 2:
Create the new solution
Click on New Solution

Step 3:
In the solution option give –
Give the name of the solution and publisher of the solution and then click on create

Click on created new solution
Step 4:
On the command bar, select New > More, and then select Environment variable.

Step 5:
On the right pane, complete the information, and then select Save:
Display Name: Enter a name for the environment variable.
Name: The unique name is automatically generated from the Display name, but we can change it.
Data type: Select from Decimal number, Text, JSON, Two options, Data source, or Secret.
Current Value. Also known as the value. This property is optional and is a part of the environment variable value table. When a value is present it will be used, even if a default value is also present. Remove the value from your solution if you don’t want to use it in the next environment.
Default Value. This column is part of the environment variable definition table and is not required. The default value is used if there is no current value.

In the above environment variable I select the data type as data source and connector SharePoint as I select SharePoint connector it will automatically connect to the SharePoint.
Then select parameter type is site for site Variable and then select the current site which we use for our Power Automate.
And then click on Save.
Step 6:
Same as the site variable I create one more variable for list which is store on that site.

How to use environment variable into Power Automate?
Step 1:
Create a flow into solution.
Click on New -> Automation ->cloud flow -> instant flow

Step 2:
Give name to flow and select how to trigger the flow and then click on create.

Step 3:
Then select the desired environment variable.

Step 4:
After adding environment variable save the flow and test the flow.

Step 5:
Provide the initalizevariable_value as item id from the list.

We can see the flow ran successfully.
Hope you understand about the Environment variable.
Thanks
Have a nice day:)

You must be logged in to post a comment.