Show View if questions

I am working on restricting views in my app and we are not having success with the expression.

We have useremails and groups in a table with column headers useremail and role.

We want to allow access to the view if the current user is within the useremail and the role matches the role required to view the table.

I tried this but it just made the view not visible to anyone.

AND(IN(CURRENT_USER,OPS USERS[USEREMAIL],IN("UGA",OPS USERS[ROLE])) 

Any help would be greatly appreciated.

0 6 79
6 REPLIES 6

Aurelien
Google Developer Expert
Google Developer Expert

Hi @antproberts 

Can you try instead:

 

AND(
  IN(USEREMAIL(),OPS USERS[USEREMAIL],
  LOOKUP(USEREMAIL(),"OPS USERS","USEREMAIL","ROLE")="UGA"
  ) 

 

For reference:

Limit users to particular tables, views, and actions - AppSheet Help

https://support.google.com/appsheet/answer/10107410?hl=en&sjid=4139218821631722607-EU

Unfortuneately this does not work either the view just disapears 

Can you share pictures of:

- data in your table for a specific user email (feel free to use a fake email such as t@t.t)

- preview pane with this useremail entered such as below, on the view you are testing:

Aurelien_0-1706794854814.png

 

Note: Please note at the outset that hiding a view from certain users does not necessarily stop the underlying data reaching user's device. A view's show if merely hides the view icon ( and hence) view from the user's device. For a more secure implementation, please evaluate use of  security filters.

For hiding views based on role, please try the below approach.

Please create a VC called say [Role_Email] with an expression something like CONCATENATE( [Role],"-", [USEREMAIL])

Now in the show if of the view , please try an expression something like 

IN( CONCATENATE( "UGA","-", USEREMAIL()),  OPS USERS[Role_Email])

The above will work for the view which needs to be shown for the role "UGA"

You will need to change the role such as "UGA" in each view's show_if expression depending on the role for which that view is to be shown.

Unfortunately, this does not work the view just disapears. 

COUNT(
SELECT(Usertable[KeyField],
AND([useremail] = USEREMAIL(),
IN([ROLE],LIST("Admin","Viewer","User")))))>0

Include roles in the LIST() of who should be able to view that page.

 

Top Labels in this Space