User Attributes, essentially user groups

It would be great to be able to set attributes against users, either a text field, EnumList field or Enum field.
The purpose of this is to be able to assign users to groups.
In my example I have dashboards that I want some users to be able to see and not others depending upon what department they are in.
In this example I have 3 users.
We have a field called USERATTRIBUTE1 that we can set as an ENUM and I have a number of options; ITS, CIVIL, ROAD LIGHTING, ITS/CIVIL, ITS/ROAD LIGHTING, ALL, CIVIL/ROAD LIGHTING
It would be good to be able to use the showif function of a view to set showif or([USERATTRIBUTE1]=โ€œITSโ€,[USERATTRIBUTE1]=โ€œITS/CIVILโ€,[USERATTRIBUTE1]=โ€œITS/ROAD LIGHTINGโ€,[USERATTRIBUTE1]=โ€œALLโ€) or any of the others so that I can essentially set access to views.
It is painful to have to use USERNAME() as that can be inconsistent depending upon the authenticor as well as having to add new users in to many different places.
This way we can create all the combinations we need and have complete control in a very simple way.

Solved Solved
0 11 975
1 ACCEPTED SOLUTION

Sounds like a user table would suit your needs.

View solution in original post

11 REPLIES 11

Are you aware of the USERSETTINGS table? Maybe this will work for your needs?

Sounds like a user table would suit your needs.

This got me thinking about the best use of user settings table vs a Users table in your data source.

I see a major limitation, in my very limited research, of the following:

โ€œUnlike normal tables, the user settings are stored on the device itself, not in the cloud. Consequently, user settings do not follow the user between devices.โ€

My users will probably go between a desktop and a mobile device. Based on the above, they could have different values in the Appโ€™s user settings table.

Plus, using a Users table in my data source allows an Admin to add new users. I donโ€™t see how that is possible in the appโ€™s user settings table.

What do you use? Any good scenarios on why one is better than the other?

I havenโ€™t had a chance to do any testing as yet but I am certain that USERSETTINGS wonโ€™t work for me since I canโ€™t rely on the user choosing the data they need to see. In this case I donโ€™t want the user to see the views they shouldnโ€™t.
The UsER table seems like the way to go however I am unsure about the syntax to use in the showif setting of the view but I will figure it out quickly if itโ€™s possible, which Iโ€™m sure it is.

One thing that I am doing is applying an admin pin in user settings that allows editing, show fields and views etc that only an admin should be able to see/perform. That works really well and allows changes within the app that would sometimes cause a duplicate
spreadsheet in OneDrive due to admin manipulation at the same time as user edits in the field. This also allows me to enable fields for manual entry to override update actions.

I guess I figured that ENUM fields against users would stop having to double up creating a user for access as well as adding them to a user field but the user table will work Iโ€™m sure.

The idea would be to have a table or slice with only the single row of the current user. Then you can access a columnโ€™s value using ANY(): ANY(UserTable[Email]). So long as you ensure UserTable contains only the row of the current user, this is a good way to access the userโ€™s values. For Show If, you might have something like ("Admin" = ANY(UserTable[AccessLevel]) to show the column if the userโ€™ has admin-level access.

Steve, Iโ€™m still very new to AppSheet but I donโ€™t see how this would work in an app with many concurrent users. Wouldโ€™t additional users simply over-write the info from the most current, last, user who is probably still using the app?

Suppose you have a table named UserTable, with at least a column named Email that identifies each user;s email address. Your app could have a security filter with a filter expression of (USEREMAIL() = [Email]) to filter out all but the current userโ€™s row. The downside with this approach is that the rows for other users wonโ€™t be available to the app should you need them, but itโ€™s very good for security. Youโ€™d have to manage the UserTable (add and remove users, e.g.) by other means.

If you need the app to have visibility of the entire UserTable, you could not use a security filter and instead use a slice (called CurrentUser, e.g.) atop UserTable, using the same filter expression given above.

So a very good rule of thumb to follow is if you are ever going to update a value it should not be in the user settings table. I have been using the user settings page to hold my userโ€™s ID and permission level via formulas within my app and it has been working perfectly until the moment I tried to update a userโ€™s settings. The settings table cannot be forced to update without the user going in and hitting save.
The user settings table should be used for things like inner filtering, like how old do I want my task list to show me, what color do I want for format rules, etc. Using the lookup/select from the User table is slightly uglier for coding but I think if I could go back I would just use the Lookups(I donโ€™t know the performance implications of using User table vs Settings but I believe Settings is MUCH faster because I have an over abundance of uses of my values from the Settings table and I have been told that the settings table is closer to calling a variable than querying a table).

@Lucinda_Mason @Steve @Mordan74

I initially suggested USERSETTINGS becasue I thought we could set Show? to โ€œoffโ€ and then from the app control/reset the settings. But based on this commentโ€ฆ

โ€ฆI am gathering that once the initial value is saved onto the device it cannot be updated from the app without user intervention? That, I did not know!! So, if that is the need then a custom UserTable would be the way to go.

BY THE WAY, I have some time back, submitted a request for an APPSETTINGS table. The initial thought was for โ€œstaticโ€ type of settings we might want to use throughout the app. But, based on this discussion, I could see a use for conditional settings as well. Please check out the Feature Request, add comments and vote it up!

This gave me enough to head in the right direction.
I created a UserTable and created columns for IsSomeRole, Yes/No. Then create something like any(select(UserTable[IsAdmin],([UserEmail]=USEREMAIL())))=Y
Obviously users have to sign in but this gives me the ability to stop editing, showing at the record level, add, edit, delete at the action level and just show at the view level.
It works perfectly.

Steve
Platinum 4
Platinum 4

Moved to #ask.

Top Labels in this Space