June 23, 2025

How to update environment variables automatically with Power Automate

The other day, I cool question that I didn’t have the answer to, but got me super excited to find a solution. How can we update environment variables automatically?

The use case is simple. Let’s say that we have a variable that is used in a lot of Flows, but the data changes periodically. For example, let’s say that you have multiple flows converting from USD to EUR and want to keep the currency exchange value. You can use an environment variable to do it and then use it in all your Flows. However, this value changes periodically, and having someone update it is tedious, so it would be great if Flow could update that value automatically.

So in the spirit of the website, let’s find out together. If you’re in a hurry you can jump to the “Update the value” section and follow the steps.

Setup

Let’s create a test variable and a Flow that reads it. Let’s use incredibly creative names:

The idea is to have a variable to update, a place where we can retrieve the value, and another place where we can update it. Then, we can recheck the value and see if it was updated.

Sorry for the creativity of the names, but clarity is more important in this case. 

Where to find the information?

Now that we have an environment to test let’s see where we can find the information, let’s go to Tables:

Usually, a new window opens. You’ll see a huge list of environment variables that were created automatically, so it’s best to search for the following:

Please don’t forget to select “All”, otherwise you won’t see anything

Click “Environment Variable Definition”.

It’s possible that your variable is not listed, so please expand it until you find it.

You can see in the list that there are more columns related to the variables. Let’s expand it and see what we get:

Don’t forget to save once you pick the “Default Value” and “Display Name”.

Here’s what we get:

This is the value that we want to get.

There’s also an “Environment Variable Value” that we’ll use in the Flow that we’ll build.  To see the values, you can do exactly like before and expand the following columns to see your value:

If it’s easier, you can update the values directly in the “Environment Variable Definition,” and it will work.  I admit it’s a bit confusing how it’s organized internally and how it’s displayed, but I wanted to show you where to find it so that the following steps make sense. In this case, to update the value, you need to go to the “definition”; however, as long as you know what to do, it’s quite easy to do so. 

Read the information

Now that we know where the variables are stored internally let’s create a Flow where we can read the information. This is a super simple flow using a “compose” action that references the variable.

Here’s what we get.

We can open the value to double-check that it’s correct.

It may look like a useless step, but we want to simulate using a variable inside a Flow so that we’re sure that the value is updated correctly.

Update the value

Okay, now that we know where they obtain the value and have a way to verify its accuracy, let’s update it.

Fetch the values

To start, let’s fetch the values. We know that it’s in Dataverse so that we can use the “List rows” action. 

Power Automate will probably return something like this:

Your flow was saved, but with a warning: Action 'List rows' has does not have a select query, filter query, or top parameter. Updating action 'List rows' to use OData filter queries can improve the performance of your flow. Learn more: <https://aka.ms/listrowsfilters>

Don’t worry about it. This indicates that we’re fetching all data, which is not recommended. It’s a reasonable notification, but we’ll filter the data. I only want it to display the data once so that we can build the filter expression together.

Analyze what we get

When you run it, you’ll get something like this:

Let’s see the outputs. It’s a lot, but if you start scrolling down, you’ll see something like this: 

Each value will have a definition like this, so this is where the data will be stored. So keep the value “EnvironmentVariableDefinitionId.” Now, let’s find the value inside this key that we need. If you scroll further, you’ll see two familiar keys. The “displayname” and “schemaname”. It’s possible that the first value is not the one you’re looking for, but it’s probably another env variable that was created in your environment. The “display name” will have a familiar name that you or someone else defined. If we look at our variables, they should have “test_env_variable” and “cr7b8_test_env_variable,” respectively.

Please always use the “schemaname” to do operations. Power Automate generates an unique name automatically when you save the variable for the first time, so we’re sure that there won’t be any other variable with the same name.

Search for our environment variable

Okay, let’s build a search in the “List Rows” to retrieve the value we want to update. To do this, we’ll use the values that we got in the previous steps like this:

EnvironmentVariableDefinitionId/schemaname eq 'cr7b8_test_env_variable'

The values should look quite familiar from before. So here’s what’s happening. We’re telling Power Automate to filter all values where:

  • EnvironmentVariableDefinitionId exists and,
  • schemaname is equal to “cr7b8_test_env_variable”

Remember before that the “schemaname” was under the “EnvironmentVariableDefinitionId” so that’s why we have the “/“.

I found an issue where if the environment variable didn’t have a valid “Current Value,” it would not show in the filter, even if the “Default value” was filled in. Please make sure that the value exists.

We’ll get something like this:

Update the values

Now that we have the value, let’s update it. To do that, we can use the “Update Row” action for Dataverse. We need to be careful when picking the ID, as common sense will likely lead us to search for a field called “ID.” There are a few options, but not the ones we need. I recommend searching for “unique” and picking “Environment Variable Value.” 

Notice that we get an “Apply To Each” action that is created automatically. This is because the previous action is a search and will always return an array, even if it’s only one value. However, since we’re using the “schemaname”, we’re sure that the value is unique, so we can safely update it.

Now let’s run and see what we get:

It runs correctly, but this doesn’t mean it worked. Let’s take a look at the environment variable value. 

Success! 🎉

Testing our code

Now run your original “Read environment” Flow and you’ll get:

With this, we’re sure that we update the value correctly and that the other Flows will pick up the values automatically. 

Final Thoughts

I know that this post is a little bit verbose. I tried to cater to both people who need a solution quickly and those who want to learn why things are the way they are. This is a simple solution that has a few “gotchas,” so I hope it helps you in some way.

You can follow me on Mastodon (new account), Twitter (I’m getting out, but there are still a few people who are worth following) or LinkedIn. Or email works fine as well 🙂

Photo by Georg Eiermann on Unsplash

 

Manuel

I have 20 years of experience in automation, project management, and development. For the past 6 years, I have been writing for this website, sharing (what I think are) valuable insights and information with readers. I strive to use my expertise to create compelling and informative content that resonates with you and, hopefuly saves you time.

View all posts by Manuel →

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon