Today I tried to display the current environment in a canvas app in Power Apps. This was slightly harder than expected.
Power Platform connectors
Table of Contents
there are quite a few Power Platform connectors that I hoped to use. Just to name a few Power Apps for Makers, Power Apps for Admin and even Power Platform for Admins. But none of these gave me the option to get the current environment’s name
So I had to make an escape into Power Automate. No not the connectors, I had to create a speedy flow!
Get the current environment Id
Then the flow will return the output from my compose action back to the flow.
Now all I have to do is to create a button and display the environment in my app.
The code to display the environment is a simple concatenation of texts. But this is not really that nice. We want the environment name. We could of course have collected the name within the flow, but you might want to use the environment id for other things too.
Ok, so that GUID is not very nice.
Get the current environment name
A small change tot he Button’s code will resolve this issue. The flow is still called by the app and the environment Id is collected. Then the Is is used within the PowerPlatformforAdmins connector to get all the details for a single environment.
Set(varEnvironmentID, GetEnvironment.Run().result); Set( varEnvironment, PowerPlatformforAdmins.GetSingleEnvironment(varEnvironmentID).properties.displayName)
And now we have the environment name displayed in the app.