I need a certain user to only be able to see the rows where he is added, i am new using the platform
Hi @Gabriel_Luezas and Welcome to the Community !
So, I’m not really in front of my computer at the moment but you could create a Users
table where each row would store one user (in a People
field) and give to each user a role (Admin, user, etc…)
Something like this :
The roles here are just stored within a simple single select list, but you could also store those in their own table and use a Relation
field to give a role to each person or, depending on your use case scenario, even a checkbox could do the job …
In this case, the Admin
role implies that I can see everything whenever I want and the User
role I gave to my other account (the 2nd one on the screenshot) would be the one limited to “where added only”
In the next screenshots, there’s an unfiltered Source
table where I’ve selected people in the multi select People
field for each row in the table and then there’s a [View of Source]
which is a filtered connected view of the table Source
displaying rows depending on the role I gave to the user in the Users
table
Here’s what I see as an Admin
And here’s what I see as a User
And the Filter
formula I used on the connected view [View of Source]
is :
Users.Filter([Select list - Roles] = User).Name.WithName(User_Only,
User_Only.Contains(User()).Not()
OR
(thisRow.People.Contains(User_Only) AND thisRow.People.Contains(User()))
)
Where :
Users.Filter([Select list - Roles] = User).Name.WithName(User_Only,
...
)
Filters the table Users
and retrieves the people with a User
role which is then stored within the named value User_Only
(WithName()) so it can be re-used later without recalculating it.
And then I ask the Filter
this :
User_Only.Contains(User()).Not()
OR
(thisRow.People.Contains(User_Only) AND thisRow.People.Contains(User()))
Where :
User_Only.Contains(User()).Not()
The first condition returns true
if the value stored within User_Only
(previously returned by the Filter()
formula) doesn’t contains the current user (User()).
In other words, it will return true
if the current user is an Admin
(as there are only 2 roles here)
OR
thisRow.People.Contains(User_Only) AND thisRow.People.Contains(User())
The second condition of the Filter
will return true
if :
-
the value in
thisRow.People
contains the value withinUser_Only
.
So it compares the values in the fieldPeople
in the tableSource
forthisRow
to the value withinUser_Only
.AND
-
the value within
thisRow.People
contains the user currently looking at the doc (User()
)
Both conditions for this 2nd condition here needs to be true
(a row in the table Source
needs to contains a “User
only” person in the field People
and the “User
only” person needs to be looking at the doc) for the filter to do its job and return the appropriated rows
Depending on your use case and current setup, this might need some adjustments though… as I could only test this with 2 accounts only …
E.g.: You might want to use this Filter()
formula instead to apply the same logic for each user’s role you might need but the Admin
one :
Users.Filter([Select list - Roles] != Admin).Name.WithName(User_Only,
...
)
or this one if you wish to limit the visibility of some rows for different roles…
Users.Filter([Select list - Roles].Contains(User,[Another limited role])).Name.WithName(User_Only,
...
)
But I hope this helps a little !
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.