cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tsparkman
Helper I
Helper I

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
WarrenBelz
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
WarrenBelz
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

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

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (59,855)