cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jsalaz1989
Helper I
Helper I

Can't read an environment variable

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: 

Jsalaz1989_0-1612519792322.png


Then inside the flow I test it out, for example, by initializing a variable to that environment variable:

Jsalaz1989_1-1612520363242.png

 

But when I test the flow, the value simply is the string "new_SharedMailbox":

Jsalaz1989_2-1612520430591.png

 

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User II
Super User II

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'

EnvironmentVariableDefinitions.png

 

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']}'

EnvironmentVariableValues.png

 

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']

 sharedmboxsetvariable.png

View solution in original post

3 REPLIES 3
Expiscornovus
Super User II
Super User II

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'

EnvironmentVariableDefinitions.png

 

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']}'

EnvironmentVariableValues.png

 

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']

 sharedmboxsetvariable.png

View solution in original post

@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)


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (46,127)