Show data for the relevant user only

I would like to know how to make the app in such a way that users can only see the information they have added to the database and not the data entered by others. Is there a tutorial somewhere on how to set this up? Thanks.

1 18 3,119
18 REPLIES 18

Hi @Peter_Razenberg Depending on what level of security you need, Check out Slices, Private tables and Security Filters.

Hi @Lynn , I have already looked for information on these three topics before posting my question here. So far I am unable to locate a useful tutorial or description on how to set this up. Do you perhaps have a link to documentation with a step by step instruction?

@Peter_Razenberg If you havenโ€™t already, you can search AppSheets YouTube channel. Maybe there is a video there. Possibly search YouTube for โ€œappsheet Security Filtersโ€. I have done this and there are some promising videos.

Channel

Search by "appsheet Security Filters"
https://www.youtube.com/results?search_query=appsheet+Security+filters


Short of finding what you are looking for, in NutShell, setting up Security Filters to filter by Logged In user is simple. Youโ€™ll need to do these things:

  1. Make sure the data tables you wish to filter have a column to record who entered the data by their Login email address (i.e. USEREMAIL() function). NOTE: Not all tables will require a security filter.

  2. Turn on the โ€œrequires loginโ€ feature of the app. Youโ€™ll need to be able to capture who is entering the data and you can use the USEREMAIL() function which contains the logged in email address.

  3. Navigate to Security -> Security Filters in the app editor to see a list of tables you have added so far.

  4. For the table(s) you wish to have filtered by the user, open the table and insert the expression below.

Expression
USEREMAIL() = [User Added Email]

Example of opened table showing Security Filter location

That is basically it! You can of course get more sophisticated with the Security Filter expressions depending on your needs for filtering.

I know you probably want more information but this can at least get you started.

Thanks @WillowMobileSystems, this really did help. I used user() instead of usermail() but I am now getting the result I was looking for.

Awesome! Wait! thereโ€™s a USER() function? What does it get assigned?

From what I can see it is using my username linked to the google account I logged in with. For me this is sufficient at this moment. No idea yet if their are any limitations for using user() over usermail().

@Steve I have seen the docs you have created for USEREMAIL(), USERROLE(), USERNAME()โ€ฆdid you know there was also a USER() function?

@Peter_Razenberg
The only trouble you might run into is if two users have the same username. The users do not all need to be from the same authentication provider (e.g. Google, DropBox, SmartSheet, etc) so there can be duplicates across providers.

User emails will be unique so youโ€™ll never run into a clash.

Sorry John, you are right. I used username() and not user(). Sorry about that.

Not a problem. I simply thought you had discovered a function that wasnโ€™t known yet - at least in the support articles. Thanks for clarifying!!

I did not. Expression Assistant tells me there is no such function.

Peter,

Make sure you read the warning at the end of this article regarding UserName in Security filters. https://help.appsheet.com/en/articles/1128148-limiting-users-to-their-own-data

We normally recommend using UserEmail rather than UserName for the reason described in the article.

Hi guys

I want users to be able to see their own data which is beautifully achieved using the solution you have provided of using security filters. However, I want the managers to be able to see all of the data. How do I do that?

I used IF(USERROLE()="Admin", true, USEREMAIL() = [Added By]) but this does not work and shows any user all of the data. 

If I only do USEREMAIL() = [Added By], that works fine but I am unable to provide the admin access to view all data. It was working fine earlier, but it just suddenly decided to stop working. Any suggestions?

Please post a screenshot of the non-working IF() expression.

Are your users all configured as admins?

Steve_0-1657563403994.png

USERROLE() will return Admin for users configured like (1).

Paras_Sood_0-1657581841425.png

Above is the screenshot of the expression I've used

Paras_Sood_1-1657582005998.png

R has the email ID op, but he can see all the records added by T.

 

 

Paras_Sood_2-1657582130021.png

Both op email ID (R) and pa email ID (T) do not have admin user role

Steve
Platinum 4
Platinum 4

Hmmm... It certainly appears like it should work. Have you tried testing from a browser window? Perhaps the app emulator in the app editor is misbehaving.

Yeah you're right, it works fine on the browser. This is a bug with the app emulator. Thanks Steve!

Top Labels in this Space