How to stop users from selecting anybody but themselves?

I’m testing features in Appsheet and I am looking at a user only being able to select their own name from column drop down list(no other users) or having that columns already be prepopulated based on the useremail. How would I go about doing that?

Example:
image

The user would only be able to pick their own name or the column will only show (uneditable/readonly):
image

Hello @DanielRPaperWorkPros, the best way to do that would be to implement a current user system, more about that here:

If you had that in your app you could easily dereference any information about your users based on their email.

2 Likes

Already have user table but I can’t get the dereferences to work

Nice, do you have a CurrentUser slice?

Yes:

With a current user table i meant a table like this:

So that you can pull any given column using a expression like this:

INDEX(CurrentUser[Role],1)

You could also use an expression to match the email of course, for example:

LOOKUP(USEREMAIL(),"Users","Email","UserId")
2 Likes

like this:

image

It seems to be working:
image

But will it change if another user was logged in ex. Joe Smoe (instead of Daniel Reiling it would say Joe Smoe in grayed out text in the box)?

Yes, that’s exactly how it works, you can try the app using the “preview as” functionality to see this for yourself

image

2 Likes

Awesome I did the steps above and its working as I imagined it. Thank you. Another question though, the user is only able to see their own entries which is what I want

, but I would like the admin to be able to view all entries (both Daniel Reiling and Joe Smoe). How would I use this slice for that?

For that you only need to add a condition to your slice expression, for example:

IF(
    INDEX(Count Per User[Role],1)="Admin",
    TRUE,
    IF(
        INDEX(Count Per User[userId],1)=[userId],
        TRUE,
        FALSE
       )
)

This expression checks if the user is an Admin first, if he is, then it returns all rows by always returning TRUE for each and every row.

If the user is not an admin, then it compares the row’s userId to the current user userId

1 Like

Alternatively:

OR(
  IN("Admin", Count Per User[Role]),
  IN([userId], Count Per User[userId])
)
3 Likes

What a smooth expression

2 Likes