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

@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")
	)
)
1 Like

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