web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How can I update an en...
Power Apps
Unanswered

How can I update an environment variable from a flow

(0) ShareShare
ReportReport
Posted on by

Hi, great to see it's now easy to read an environment variable in a flow (provided the flow is created within a solution!) but how to update the value of the environment variable from within the flow?

 

I assume I will need to use the Dataverse connector's Update a Row function so I start by retrieving the environment variables UID using 'List rows' : -

1.png

This appears to work and I can reference the UID using: -

 

first(outputs('Get_SMSyncInitialise_UID')?['body/value']?[0]?['environmentvariabledefinitionid'])

 

BUT when I try and reference that UID to update the environment variable record ...

 

2.png

 ... I receive the error: - "Bad Request - Error in query syntax."

 
Stumped 😞 Any pointers please?

 

Cheers

I have the same question (0)
  • Verified answer
    EricRegnier Profile Picture
    8,720 Most Valuable Professional on at
    Re: How can I update an environment variable from a flow

    Hi @Anonymous,

    You're setting the row ID of the update step to "Environment Variable Definition" ID, but should be the row ID of "Environment Variable Value". In the "GetSMSSyncInialise" list row step, use the "Expand Query" to include related environment variable values. This will give you the "Environment Variable Value" ID to update. Then iterate from the rows returned and update the value within the loop.

    Hope this help! 

  • Verified answer
    Community Power Platform Member Profile Picture
    on at
    Re: How can I update an environment variable from a flow

    Thank you @EricRegnier for pointing me in the right direction

     

    In the end, instead of using an Expand query for List Rows I used the excellent FetchXML Builder tool (from XRMToolbox) to generate an XML Query that pulled out just the UID as follows: -

     

    <fetch>
      <entity name="environmentvariabledefinition" >
          <filter>
            <condition attribute="schemaname" operator="eq" value="hdc_SMSyncInitialise" />
          </filter>
        <link-entity name="environmentvariablevalue" from="environmentvariabledefinitionid" to="environmentvariabledefinitionid" >
          <attribute name="environmentvariablevalueid" alias="envUID" />
        </link-entity>
      </entity>
    </fetch>

     

    ... and the expression: -

    first(body('Get_Environment_Variable_UID')['value'])['envUID']
     
    ... in the Update a Row 'Row ID' field.

     

    All working 🙂

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 819 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 308 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 222 Super User 2025 Season 2

Last 30 days Overall leaderboard