Access to views based on condition

Hi everyone. I recently posted about a similar topic which I thought had solved my Problem but now I have gotten rather stuck again.

IN(LOOKUP(USEREMAIL(), "UserManagement", Email,Role), LIST("Site Head" "NY"))

I am trying to use this expression to limit the users that can see certain views based on custom roles I gave them in an external UserManagement table. The function works if the user has exactly the required roles but if as an example I also want the admin to be able to see the view I thought I would need to add an OR(). So I came up with this second expression.

OR(IN(LOOKUP(USEREMAIL(), "UserManagement", Email, Role), LIST("Site Head", "NY")), IN(LOOKUP(USEREMAIL(), "UserManagement", Email, Role), LIST("AppAdmin")))

This should, if I'm not completely mistaken in the way the functions work, allow anyone who has the roles "Site Heah" and "NY" or the role "AppAdmin" to see the view. Still however didn't work. Any tips would be greatly appreciated! Thanks in advance.

1 4 81
4 REPLIES 4

You would benefit from implementing the current user system in your app. If you search for it you should be able to find a post that was made several years ago that's got a lot of nuance and specifics, sometimes the post is hard to find. 

Now,now @MultiTech don't be shy!!

It was @MultiTech who came up with the "Current User" system that many of us now use in all our apps.  Highly recommend using it!!  Here is the link to the Tip article...

https://www.googlecloudcommunity.com/gc/Tips-Tricks/Current-User-Slice-How-to-conform-your-app-aroun...

 

Thank you very much guys!

Steve
Platinum 5
Platinum 5

I would suggest you create a slice of the UserManagement table named (e.g.) Current Roles with a row filter expression of:

(USEREMAIL() = [Email])

Then, to determine if the current user has a single role (e.g., AppAdmin), you could use:

IN("AppAdmin", Current Roles[Role])

To determine if the current user has all of several roles:

ISBLANK({"Site Head", "NY"} - Current Roles[Role])

Or to determine if the user has either of (all of several) or (one other):

OR(
  ISBLANK({"Site Head", "NY"} - Current Roles[Role]),
  IN("AppAdmin", Current Roles[Role])
)

 

Top Labels in this Space