Use Table To Select Which Views User Can See

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,539
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

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:

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.

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