Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Can't read an environment variable

(0) ShareShare
ReportReport
Posted on by

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

 

 

  • Expiscornovus Profile Picture
    31,648 Most Valuable Professional on at
    Re: Can't read an environment variable

    Hi @MarrinerDev,

     

    That doesn't sound ok. I will have a look in that other thread.

  • MarrinerDev Profile Picture
    on at
    Re: Can't read an environment variable

    Hi @Expiscornovus, thankyou for going to the trouble of replying but it is precisely that section "Environment Variables" which does not show up for me at all in the Dynamic Content panel (even though the same variables are accessible in a test PowerApp I built in the same environment.

     

    I posted more detail in this Power Automate thread:

    Environment Variables section not showing in Dynam... - Power Platform Community (microsoft.com)

     

  • Expiscornovus Profile Picture
    31,648 Most Valuable Professional on at
    Re: Can't read an environment variable

    Hi @MarrinerDev ,

     

    Since this thread was posted things have changed a little bit.

     

    They have introduced the environment variables feature within the dynamic content section of actions in Power Automate. They should show up there now:

    https://docs.microsoft.com/en-us/powerapps/maker/data-platform/environmentvariables#use-environment-variables-in-power-automate-solution-cloud-flows

     

    environmentvariables_improvement.png

     

     

  • MarrinerDev Profile Picture
    on at
    Re: Can't read an environment variable

    What a piece of crap!

    Microsoft should be ashamed of themselves making such a fundamental piece of functionality such a mess. Dataverse (and Solutions) are a total useless croc... 

    Environment variables - whether used in a canvas app or flow - should be immediately accessible ANYWHERE building your app/flow from a menu like this: Insert->EnvironmentVariable->VarName.  That's it. Period.

    I've been building C++/COM/.Net/SQL for 25 years and I've rarely seen such an amateurish unfinished mess as the Power Platform. If you want grown-ups to use it Microsoft, (and I don't mean modern day equivalent of VB numpties) fix it...

  • Jcook Profile Picture
    7,770 Most Valuable Professional on at
    Re: Can't read an environment variable

    Hey @Anonymous 

     

    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)

  • Community Power Platform Member Profile Picture
    on at
    Re: Can't read an environment variable

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

  • Verified answer
    Expiscornovus Profile Picture
    31,648 Most Valuable Professional on at
    Re: Can't read an environment variable

    Hi @Anonymous,

     

    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-deployments/

     

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,708 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,030 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow