Owners, Co-Owners and Users
Power Apps has 3 types of users.- Owners
- Co-Owners
- Users
Enable controls for owners
Ideally, I want to make my app as simple as this:
Depending on a variable I can display a text or enable or disable a button, icon or any other control.Adding a Timer
The following code is using the PowerAppsforAdmins and the PowerPlatformforAdmins connectors to get the details of the current app.The code could be added to the App start however this will slow down the start of my app and I don’t want that. Therefore I’m adding this to a timer that will set my isOwner after the app has been started. My thought here is that it is ok for the advanced options to appear a little later.Set(
isOwner,
First(
Filter(
PowerAppsforAdmins.GetAdminApps(
First(
Filter(
PowerPlatformforAdmins.GetAdminEnvironment().value,
properties.displayName = "Pieter Veenstra MVP (default) (org0681189e)"
)
).name
).value,
properties.displayName = "Owner App"
)
).properties.owner.email = User().Email
);For the above code to work, all I needed was the Environment Display name and the display name of the app. You could hard code this if you want to speed things up a bit.Identify a Co-Owner
Now I need to identify the Co-Owners but where earlier I was able to use properties.owner from the app. There isn’t anything for co-owners
Time to have a second thought on this.Last Modified By
How using the Last Modified By property?Set(
isEditor,
First(
Filter(
PowerAppsforAdmins.GetAdminApps(
First(
Filter(
PowerPlatformforAdmins.GetAdminEnvironment().value,
properties.displayName = "Pieter Veenstra MVP (default) (org0688189e)"
)
).name
).value,
properties.displayName = "Owner App"
)
).properties.lastModifiedBy.email = User().Email
)Now all we have to do is save the app and all the controls controlled by isEditor will become visible to only you. As there can only be one editor any any one time anyway, the use of last modified by seems to be a good option to enable controls for owners.Frequently asked questions
How does the example identify the app owner?
It retrieves app details using administrator connectors and compares the owner email with the current user’s email.
Why does the article use a timer for the owner check?
The author places the check in a timer after startup to avoid delaying the initial app load.
Does lastModifiedBy identify every co-owner?
No. The article experiments with the last-modified user as a proxy; that value does not establish a complete list of co-owners or replace server-side authorization.
