Filtering data and views based on user roles/classes

As of now I filter data and views by straight away putting useremail() directly in the show_if or other contingent fields. Like show if useremail()=“abc@xyz.com

Which will be a problem when the users increase.

For that I have assigned each user a user role (there are four roles as of now, with prospects to diversify in the future), and I wish to filter data and views based on that role, rather than using useremail() directly.

So, is there a way to do that by using class-emails like admins@xyz.com, moderators@xyz.com ? Maybe I have seen something like that.

Or do I have to bring up the ‘role’ value for each user for achieving that? If so, then I guess that I have to use dereferences after making a virtual column in every sheet that records the useremail and dereferencing that role corresponding to user-email in the employee page.

Am I on the right track, or far from it?

Solved Solved
0 11 3,294
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Best to have a table that describes your users, including their email address and roles. Then in your Show_If expressions, you could do something like:

ISNOTBLANK(
  FILTER(
    "Users",
    AND(
      (USEREMAIL() = [Email]),
      IN("ExpertUser", [Roles])
    )
  )
)

View solution in original post

11 REPLIES 11

Steve
Platinum 4
Platinum 4

Best to have a table that describes your users, including their email address and roles. Then in your Show_If expressions, you could do something like:

ISNOTBLANK(
  FILTER(
    "Users",
    AND(
      (USEREMAIL() = [Email]),
      IN("ExpertUser", [Roles])
    )
  )
)

@Steve I’m doing something similar but can’t get it to work.

Users table with User_NO as key. USER_EMAIL and Key_Prayer are fields I need to evaluate.

On a Show_IF for a UX.Form based on a slice from the Requests table, I only want the logged in user
USEREMAIL() to see the form if their record USERS.Key_Prayer =TRUE

I’ve tried numerous expressions but they all fail to limit it to the condition I want to use, list above.

Do you, or anyone else, need more info to help me? Thanks.

@Lucinda_Mason, I’m not clear on exactly what you’re trying to accomplish.

The Show If expression of a view in a non-ref position determines whether the view is shown or hidden in its designated position. Show If has no effect on views in the ref position.

Can you explain further what you’re trying to do?

In a form’s Show_If: Something like this: IF(LOOKUP(USEREMAIL(), “Users”, “USER_EMAIL”, "KEY_PRAYER”)=TRUE,TRUE,FALSE)

When, if the current user’s record in the Users table (matched via email) has the column Key_Prayer = True. Then the form can show. If Key_Prayer=False, then the form won’t show.

Where would you expect the form to show?

I have a deck view that serves as a menu. I don’t want the link to appear here, yes that is probably one of the issues.

The top one should only appear when the conditions I listed earlier are True. I’m really confused now, so I totallly understand if I am making NO sense.
3X_4_2_42cc7c1f1c673f5a922415a7e6be2e8cc88c9ad0.png

Ok @Steve, you got me in the right direction.

I used:
LOOKUP(USEREMAIL(), “Users”, “USER_EMAIL”, "KEY_PRAYER”)=TRUE
in the row filter condition for the menu slice that pulls the data to appear on the table view.

Now, I just have to incorporate it into the existing Row Filter I was using:

IF(ISBLANK(LOOKUP(USEREMAIL(), “Users”, “USER_EMAIL”, "PI_NO”)),
IN(99,[PI_NO]),
OR(IN(LOOKUP(USEREMAIL(), “Users”, “USER_EMAIL”, "PI_NO”),[PI_NO])
,IN(0,[PI_NO])))

Steve, ExpertUser is another table ?, the role cannot go in a column in the Users table?

No.

The role can go in a column in the Users table.

Thank you so much for everything Steve

I got error message for this Show_If expressions :

Screenshot 2023-05-17 205623.png

Top Labels in this Space