cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Setting Global Variable to Define User Permissions

Hi All - 

 

I'm new to Power Apps and am hoping someone can help. I have an app that's connected to a SharePoint site that contains two lists:

  1. Spend Requests
  2. Spend Admins

 

The Spend Admins list contains two columns:

  1. Title - this contains the user's email address
  2. Role - this contains a value of either FIN or SCM. The column type is Choice or dropdown.

 

tsparkman_0-1605795640724.png

 

In my app, I want to hide or display buttons depending on whether the logged in user's role is set to FIN or SCM. I'm thinking that I want to set a global variable in the Application OnStart to do the lookup once and assign the variable that I can then use throughout my app to set button Visible properties. I'm having difficulty with the syntax to set the global variable. Any help is greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Hi @tsparkman ,

Something like this at App OnStart

Set(varUserMail,User().Email);
Set(
   varRequestRole,
   Lookup(
      'Spend Request',
      Title=varUserMail
   ).Role
);
Set(
   varAdminRole,
   Lookup(
      'Spend Admins',
      Title=varUserMail
   ).Role
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

2 REPLIES 2
Super User III
Super User III

Hi @tsparkman ,

Something like this at App OnStart

Set(varUserMail,User().Email);
Set(
   varRequestRole,
   Lookup(
      'Spend Request',
      Title=varUserMail
   ).Role
);
Set(
   varAdminRole,
   Lookup(
      'Spend Admins',
      Title=varUserMail
   ).Role
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Thank you @WarrenBelz!

 

This was exactly what I was looking for. One small change in case others a reading to find a similar solution. I had to put .Value after Role since it is a drop-down field.

 

Set(varUserMail,User().Email);

Set(
varAdminRole,
Lookup(
'Spend Admins',
Title=varUserMail
).Role.Value
)

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (81,930)