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:
3X_e_1_e138fc2998a2aa6ed7b7251f3a9dd0eb6826f051.png

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

0 12 315
12 REPLIES 12

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.

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")

like this:

3X_f_2_f2335cdd1bc8bd2f615296d2da8631888062c339.png

It seems to be working:
3X_b_d_bdb1b843900defadec5c3259fec8aba272ef9a17.png

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

3X_d_3_d3353ad17ba1e6064f572eb1093c0bff89c9d9e9.png

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

Alternatively:

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

What a smooth expression

Top Labels in this Space