Use Table To Select Which Views User Can See

Zach_Work
Participant I

Hello,

I’ve gotten my page launcher working but I’m having trouble to show for users only the items that they are authorized to view.

For instance, I only want the users who are MEP specialists to be able to view or edit the MEP slices.

Is there a way that I can use the USER table to SHOWIF and EDITIF the user has been granted permission by the administrator?

Thank you!

Solved Solved
0 11 1,492
1 ACCEPTED SOLUTION

Hello @Zach_Work, welcome to the community !

I’d like to add one more reference material to the ones @Suvrutt_Gurjar mentioned:

View solution in original post

11 REPLIES 11

Zach_Work
Participant I

As I am a new user I was not able to include more than one image. But hopefully this will explain better. I don’t want users who aren’t MEP personnel to have access to the MEP view

Welcome to the AppSheet community.

In the Show_if of the MEP view , please try an expression something like below

IN(USEREMAIL(), SELECT( USER[EMAIL] , OR( [MEP]=“EDIT”, [MEP]=“VIEW”))

Please note that this expression will only hide the MEP view icon from the users who are not supposed to see that view. The MEP data will reach all the user’s device.

You may also wish to take a look at the relevant articles on user data access

Hi Suvrutt_Gurjar,

Thanks for the quick response.

Unfortunately, I don’t think this expression will be the end of my problem. For once I have been able to limit who can edit the MEP I will want to do the same with the other views IE. “Walls & Dec”, “Install”, and “Final”.

A better way of asking my question might be -

Is there an expression that will reference [MENU ITEMS] against the columns on the USER table to see what permissions have been allowed?

I could compromise and have all data visible but to only let certain users Edit particular tables.

Thanks again

I would utilize a Current_User slice system, as @Rafael_ANEIC-PY linked to above. From this slice, you can easily pull out any of the data from the current users record and use that in your Show If formulas for your views.

Hi @MultiTech_Visions (Matt I think?)

Thanks for the response. I understand what you are saying and it is helpful, and would work fine if I just had a single user type who should have the permission. Or if I just had one menu item to show/not show.

However, my problem is that I have multiple users who should only see certain rows on the menu and the App will need to look in different columns to find the permission.

The menu looks like this:

[MENU ITEM]
MEP
Walls & Dec
Install
Final

and the User Table heading has the same text horizontally like this:

[USER] [MEP] [Walls & Dec] [Install] [Final]

In this example, when Darryl looks at the Menu View he should not see MEP.
But when Clarice looks at the Menu view she sees all items.

Even if I use the current user slice as you have suggested, I need an array type expression in the Menu Table to show a row by matching it to a column on the User Table.

In Summary:

Is there an expression that tells the App what column on the user table to look in based on the value in [MENU ITEM]?

Thanks in advance for any suggestions.

Hello @Zach_Work, welcome to the community !

I’d like to add one more reference material to the ones @Suvrutt_Gurjar mentioned:

MultiTech
Participant V

I’m afraid you’ve got things backwards; the Current_User system is INTENDED for multiple users

  • if there is only one person using the app, there’s little need to pull the USEREMAIL() and find that record in the User table… is there? You likely wouldn’t have a User table - since there’s only 1 user.

Take a closer look at this post and what I describe:

It’s literally what you’re asking for.

Zach_Work
Participant I

Hi @MultiTech_Visions,

Thanks for your response.

I understand what you are saying, and I’ve read that post several times. Perhaps I wrote too much explanation and my question got muddled.

All I really want help with is the expression.

When I use this expression it hides ALL menu items. I only want it to hide the row that says “MEP”.
IN(INDEX(Current User[MEP], 1), list(“VIEW”, “EDIT”))

Then you need to use a slice, not adjust the views.

  • You need to create a slice of the Menu table, that utilizes data from the Current_User slice - or does a hard LOOKUP() for the email in the user table, etc. etc.

Thanks @MultiTech_Visions

The Slice of the Menu table did the trick.

For anyone who comes across this thread, I will also add that I needed to add this bit of code in the Row filter condition and it’s now showing the menu items for the users who need to see them.

OR(
IF( [MENU ITEM] = “Project”,TRUE,FALSE),
IF( [MENU ITEM] = “Dashboard”,TRUE,FALSE),
IF( [MENU ITEM] = “Project Team”,TRUE,FALSE),
IFS( [MENU ITEM] = “INSTALL”, IN(INDEX(Current User[INSTALL], 1), list(“VIEW”, “EDIT”))),
IFS( [MENU ITEM] = “WALLS&DEC”, IN(INDEX(Current User[WALLS&DEC], 1), list(“VIEW”, “EDIT”))),
IFS( [MENU ITEM] = “FINAL”, IN(INDEX(Current User[FINAL], 1), list(“VIEW”, “EDIT”))),
IFS( [MENU ITEM] = “MEP”, IN(INDEX(Current User[MEP], 1), list(“VIEW”, “EDIT”)))
)

A more streamlined version of your formula:

Switch([MENU ITEM], 
  “INSTALL”, IN(INDEX(Current User[INSTALL], 1), list(“VIEW”, “EDIT”)),
  “WALLS&DEC”, IN(INDEX(Current User[WALLS&DEC], 1), list(“VIEW”, “EDIT”)),
  “FINAL”, IN(INDEX(Current User[FINAL], 1), list(“VIEW”, “EDIT”)),
  “MEP”, IN(INDEX(Current User[MEP], 1), list(“VIEW”, “EDIT”)),
in([MENU ITEM], list("Project”, "Dashboard”, “Project Team”)
)
Top Labels in this Space