cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kostasoul
Advocate I
Advocate I

Get name of environment that flow is running in

I'd like to incorporate some logic into a flow that changes behaviour based on the environment that it is running in.

 

For example, if the environment name is 'Development', set the email address in an Outlook 365 Send Email action to a fixed value instead of an email that would get used in the production flow.


Looks like the workflow() function returns a tags object with an environmentName which has a guid, and I can potentially compare this to another run in the 'production' environment and compare the values to know if its the right value or not.  This solves the immediate problem.

 

But to make the flow a little bit more clear and that little bit more easier to debug, I was wondering if there was a way to get the name and not the guid? 

 

It looks like the Flow Management connector has a Get Flow which given an environment and flow name, you could get back the required flow, but the guid to marry this back up to the original flow isn't present.  

1 ACCEPTED SOLUTION

Accepted Solutions
DeepakS
Super User
Super User

Hi @kostasoul 

 

To get the environment "display name" you should use both workflow() and Get Environment as Admin action.

Get Environment as Admin required environment ID that you will get from : workflow()['tags']['environmentName']

Enviroment display name : body('Get_Environment_as_Admin')?['properties']?['displayName']

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
DeepakS
Super User
Super User

Hi @kostasoul 

 

To get the environment "display name" you should use both workflow() and Get Environment as Admin action.

Get Environment as Admin required environment ID that you will get from : workflow()['tags']['environmentName']

Enviroment display name : body('Get_Environment_as_Admin')?['properties']?['displayName']

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

v-alzhan-msft
Community Support
Community Support

Hi @kostasoul ,

 

Please take a try with @DeepakS 's solution.

 

Best regards,
Alice       
 
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks @DeepakS 

 

That Get Envrionments for Admins did the trick.

 

I was then able to rework the flow to have a `isProduction` variable defined with the expression

equals(body('Get_Environments_For_Admin')?['Name'],workflow().tags.environmentName)

 

which matches on the GUID, and now I have a nice variable I can test for production and change behaviour or email content.

stapes
Impactful Individual
Impactful Individual

Hi @DeepakS 

 

Can you give a little more detail on how this is done. The link (https://docs.microsoft.com/en-us/connectors/powerplatformforadmins/#get-environment-as-admin) does not appear to say anything useful.

Is it a Flow?

That link shows a list of actions to be used inside a flow. "Get Environment as Admin" is the action you should use.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,536)