cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rwittels
Resolver I
Resolver I

OnStart Set Collection (Array) of Admin Users

I might be answering my own question here so please let me know if this will work as I don't have other admin users yet. I want to define a variable which has admin user email addresses in it so that I can use the variable to control the visibility of buttons.

At this point, I have a working solution with one email address:

OnStart

 

Set(varAdmins, {Email: "myname@mycompany.com"})

 

Button Visibile Property

 

User().Email = varAdmins.Email

 

Will the button's visible property still work if I add additional users to the collection e.g.

 

Set(varAdmins, {Email: "myname@mycompany.com"},{Email: "othername@mycompany.com"})

 

My syntax might be wrong here.

Or is it as simple as something like this:

 

Set(varAdmins, "myname@mycompany.com; othername@mycompany.com")

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

In that case:

OnStart

Set(varUser,User().Email); Set(varAdmins,["myname@mycompany.com", "othername@mycompany.com"])

 

Then:

Button Visibile Property

varUser in varAdmins.Value

 

Or create a collection:

ClearCollect(
AdminsCol,
{AdminsMail:"othername@mycompany.com"},
{AdminsMail:"myname@mycompany.com"})
 
Then Visible property:
varUser in AdminsCol.AdminsMail

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

7 REPLIES 7
eka24
Super User
Super User

I will suggest the following:

OnStart

Set(varUser,User().Email)

 

Button Visibile Property

varUser= "myname@mycompany.com" Or "othername@mycompany.com"

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

I am trying to avoid changing the email addresses on every button, especially if my admin users change. Is there no way to maintain them in one place, such as OnStart, and just use varUser = varAdmins on buttons?

What about Set(varUser,User().Email) and Set(varAdmins,' "myname@mycompany.com" Or "othername@mycompany.com" ')?

In that case:

OnStart

Set(varUser,User().Email); Set(varAdmins,["myname@mycompany.com", "othername@mycompany.com"])

 

Then:

Button Visibile Property

varUser in varAdmins.Value

 

Or create a collection:

ClearCollect(
AdminsCol,
{AdminsMail:"othername@mycompany.com"},
{AdminsMail:"myname@mycompany.com"})
 
Then Visible property:
varUser in AdminsCol.AdminsMail

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

This works with my address so I'm sure it will work when I add additional addresses.

That is correct. It will work when you add more. 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

It does not work with my SendPushNotification though.

This works:

recipients: ["myname@mycompany.co.za"],

This does not work:

recipients: [varUser in varAdmins.Value],

 

I even tried creating a single variable OnStart:

Set(adminUser,varUser in varAdmins.Value)

This works great on button visibility but does not work in SendPushNotification:

recipients: [adminUser],

It also says that the data type is boolean: adminUser = true

 

Do you know what I am doing wrong?

JFbsis21
Frequent Visitor

hope the thread is still open as I am having the same /similar issue - in my case I receive a message when trying to login to Admin -saying not a valid account or similar. This is when I click on the Login as Admin button ( I am an admin)using the Help Desk app which I am trying to customize from the Help desk sample app (canvas) in PowerApps

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,061)