Hi,
I'm having trouble reading the value of an environment variable. I've created a cloud flow and an environment variable in the same solution:
Then inside the flow I test it out, for example, by initializing a variable to that environment variable:
But when I test the flow, the value simply is the string "new_SharedMailbox":
What am I missing? I've looked at a bunch of articles and I think it's supposed to be this simple, but I'm probably missing a step. FYI and as far as I know, this flow/solution is not using CDS, it's unmanaged, I haven't imported/exported anything.
Any help?
Thanks
Solved! Go to Solution.
Hi @Jsalaz1989,
If you want to read a value from an environment variable you have to query the Environment Variables Definitions and Environment Variable Values tables from DataVerse.
@Jcook has written a nice blog about this: https://flowaltdelete.ca/2020/09/09/using-environment-variables-as-parameters-for-power-automate-dep...
Below is an example of how you can read the current value of your SharedMBox environment variable and use that to set your local flow SharedMBox variable in your flow.
1. Add a list rows action, use the Environment Variable Definitions table. Use the following filter query value. The schema corresponds with Name of the environment variable, in your case new_SharedMBox.
schemaname eq 'new_SharedMBox'
2. Add another list rows action, use the Environment Variable Values table. Use the following filter query value
_environmentvariabledefinitionid_value eq '@{outputs('List_rows_-_Environment_Variable_Definitions')?['body/value']?[0]?['environmentvariabledefinitionid']}'
3. Add a set variable. Set the SharedMBox flow variable with the value of your environment variable. Use the following expression in the value field
outputs('List_rows_-_Environment_Variable_Values')?['body/value']?[0]?['Value']
Hi @Jsalaz1989,
If you want to read a value from an environment variable you have to query the Environment Variables Definitions and Environment Variable Values tables from DataVerse.
@Jcook has written a nice blog about this: https://flowaltdelete.ca/2020/09/09/using-environment-variables-as-parameters-for-power-automate-dep...
Below is an example of how you can read the current value of your SharedMBox environment variable and use that to set your local flow SharedMBox variable in your flow.
1. Add a list rows action, use the Environment Variable Definitions table. Use the following filter query value. The schema corresponds with Name of the environment variable, in your case new_SharedMBox.
schemaname eq 'new_SharedMBox'
2. Add another list rows action, use the Environment Variable Values table. Use the following filter query value
_environmentvariabledefinitionid_value eq '@{outputs('List_rows_-_Environment_Variable_Definitions')?['body/value']?[0]?['environmentvariabledefinitionid']}'
3. Add a set variable. Set the SharedMBox flow variable with the value of your environment variable. Use the following expression in the value field
outputs('List_rows_-_Environment_Variable_Values')?['body/value']?[0]?['Value']
@Expiscornovus thanks for the reply. Oddly enough I had read through that blog post before but I guess I need to follow it better. I'm sure revisiting it along with your example will work for me.
However, seeing that reading environment variables requires those list rows actions, I'm realizing I cannot use it for my 'when an email arrives in a shared mailbox' trigger, right? My original example was simple just to test environment variable usage. However, my real use case is a flow triggered by an incoming email into a shared mailbox. Therefore, it seems like I have to hardcode the mailbox address into the trigger. More generally, is it correct to assume that triggers cannot make use of environment variables? Or is there some solution to this?
Hey @Jsalaz1989
Unfortunately you're correct. Triggers cannot utilize Environment Variables at this time.
Do note that Microsoft has said in past, that the way these variables work are going to be changed for the better in the future. (Hopefully Soon)
Proud to be a Flownaut!
Check out new user group experience and if you are a leader please create your group
See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
11 | |
9 | |
7 | |
3 | |
3 |
User | Count |
---|---|
15 | |
8 | |
6 | |
4 | |
2 |