Expression to restrict which views are visible to a user based on an RBAC table

Hello,

I am trying to write an expression that will determine who can see what views. I have a table called RBAC that has columns for User Email and Views they can see. For example:

User Email | Views
xxx@gmail.com | Contacts
yyy@gmail.com | Contacts, Deals
zzz@gmail.com | ALL
aaa@gmail.com | RBAC

User xxx should only see Contacts view, user yyy should see two views (Contacts & Deals), user zzz should see all three views and user aaa should only see RBAC view. Below is the expression I wrote in โ€œShow Ifโ€ of all three views (Contacts, Deals, RBAC); however, I can only see view if I select โ€œALLโ€, otherwise the views disappear. If I replace CONTEXT(โ€œViewโ€) with the name of the view it works fine, but I wanted the ability to just use the expression for Show If for all views rather than update the expression with each Viewโ€™s name.

ISNOTBLANK(
FILTER(
โ€œRBACโ€,
AND(
[Email]=USEREMAIL(),
OR(
IN(โ€œALLโ€,[Views]),
IN(CONTEXT(โ€œViewโ€), [Views])
)
)
)
)

Any help would be greatly appreciated.

Thank you

0 2 258
2 REPLIES 2

LeventK
Participant V

@Yogesh_Patel
Try with this expression in the Show_If property of each UX View:

IF(
	CONTAINS(
		SPLIT(
			LOOKUP(
				USEREMAIL(),
				"Users",
				"User Email",
				"Views"
			),
			","
		),
		"ALL"
	),TRUE,
	CONTAINS(
		SPLIT(
			LOOKUP(
				USEREMAIL(),
				"Users",
				"User Email",
				"Views"
			),
			","
		),
		CONTEXT("View")
	)
)

Hi Levent,

I got the same message. โ€œThis formula is not evaluated in the context of a row, so column values are not available.โ€

Thanks,

Yogesh

Top Labels in this Space