Environment Variables in flows with SharePoint

Environment variables in Power Automate

When you create flows inside a solution you might have noticed these Environment Variables. What are they and what can you do with them?

Environment Variables in dynamic content

Recently these brown iconed Environment variables started to appear in Power Automate.

Environment variables in Power Automate Microsoft Office 365 image 39

When we hover over the Environment Variable we can see that the function parameters is used for this.

Environment variables in Power Automate Microsoft Office 365 image 41

When you read through the documentation of the parameters function things don’t get much clearer

Environment variables in Power Automate Microsoft Office 365 image 42

How do Environment variables work?

First of all environment variables can be created within solutions only and also flows only find environment variables within solutions. So for example in my default solution there is a Should the Peek Button Be Showed [sic]

Environment variables in Power Automate Microsoft Office 365 image 38

This environment variable appears in my flows as noticed earlier.

In your own solutions you can create new environment varibales.

Environment variables in Power Automate Microsoft Office 365 image 43

These variabales can be plain text but also yes/no, decimals, json or even a datasource.

Environment variables in Power Automate Microsoft Office 365 image 44

Well that creates a lot of options for us.

Data source type Environment Variables

A Decimal number. Text and Yes/No are hardly interesting. Yes of course you can set these variables and they are great to use, but how about a Datasource as an environment variable?

When I configure my SharePoint site like this as an environment variable:

Environment variables in Power Automate Microsoft Office 365 image 45

Then that means that in my flow I can reference the variable instead of any hard coded urls. So that makes flow like this possible. Using the SharePoint list url without any selection of the drop down values.

Environment variables in Power Automate Microsoft Office 365 image 46

Ok, that is great, but we need to put this to the real test. Using a trigger. in the past I managed to add settings to my flows using a number of compose actions or a select action near the top of my flow. But these variables that live outside my flow are so much better.

Even the editing experience is really good here!

Notice that I only set the Site address and i’m getting a drop-down with available lists! So the flow editor is environment variables aware.

Environment Variables

You can now use this to set for example your SharePoint url or anything else that makes up the difference between your development, test and production environment. Such as who to send emails to.

Imagine creating a flow that emails senior managers in your organisation. You wouldn’t want them to receive your tests in development.

But,… I hear you say. Do I need environments?

YES.

I would always recommend using multiple environments. I’ve seen many times in the past where people pre or post fixed the names of their flows with DEV or TEST or PROD. Multiple environments makes things so much easier. And now that you can use environment variables on triggers and actions it should be a lot easier to move your flows as part of a solution.

How about Power Apps?

Well my next post is ready already.

Environment Variables in Power Apps

16 thoughts on “Environment variables in Power Automate

  1. Thanks for sharing, but is there a way to move your Default environment flows and apps into your new environment without redevelopment.

  2. Thank for this valuable info. Does this feature require a specific version or permissions. This menu does not appear for me

  3. Hey,
    How would you use environment variables when deploying a flow from one environment to another? Would you change the value before exporting the solution? Or would you export and then change the value of the datasource variable…?

    1. Hi Sara,

      You can deploy variables as part of solutions, however the values will remain unique to each environment. Personally I create an unmanaged solution next to the real solution that contains just the variables. In there I maintain the values of the variables.

      1. Love this approach. Thank you for the explanation and suggested patterns!

        I created the environment variables solution and then the real solution but the flows in the real solution don’t see the environment variables. Is it a ‘wait for it’ thing?

  4. i only included them in the Env Vars solution, not the functional solution. Should they be there too?

    Yes I published w/in the environment. I have not exported/imported yet.

      1. Deploy then with the solutions and uodate the values using the environment variables only solution. As that one is unmanaged it will let you edit the variables. In the main solution you can’t edit them as that one will be managed.

  5. ok. This is working in my commercial cloud but not in my client’s gov cloud. wondering if there it’s not available to them yet.

    Thanks for your help!

    1. Can you check for the client environment what the update frequency is set to? You can find this in the Admin Center -> Selected Environment -> Refresh Cadence. This needs to be set to Frequent. Once set to Frequent it will update within the next 24 hours.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4,911 other subscribers

Recent Posts

Archive

Thank you for visiting SharePains