Vary Enum list based on USERROLE()

I’ve been using Appsheet for a month now so am still a noob. It’s been going quite well for the most part. One issue that has me stumped is how to present an Enum list to the user based on their user role.

Here’s a screenshot of the field setup. Basically I only want an Admin user to be able to select the last two options. I don’t mind if they are visible and unavailable to other users or if they are invisible to other users.

I tried using the Valid If field setting but then other users get an error message if it is set to one of the two Admin-only values.

I would also like the field not to be editable by non-Admin users if it is set to one of the last two values. Any pointers would be much appreciated.

How are you defining “admin” versus non-admin? Is that data driven in a users table of some kind? There are a few options that could work here, but it depends on how your data is organized?

USERROLE() = “Admin”

So you should likely go back to using the valid if field but you will want to add the current value in the field if you do not wish to display the error message to the non admin users.
So say your valid if is IF(USERROLE()=“admin”, LIST(“Stuff”), LIST(“non admin Stuff”))+LIST([value]).
for the editable field you would want to know if the current value is apart of the admin only list. If this is small and static just do AND([value]<>“admin value 1”, [value]<>“admin value 2”)
If you want this to be dynamic then I’ll need to know how you’re creating these list to subject a solution.

1 Like

What Austin said :slight_smile: Here’s an example with a STATIC version:
https://www.appsheet.com/samples/Built-from-your-app-spec-?appGuidString=a0843d68-260c-4bbe-8218-6fc02bd14d7f

Take a close look at the definition for the column called “Category”.

And for the rest of the columns, you would want a edit-if, if

not(in([Category],{"Special Val A", "Special Val B"} ) )

If you want this to be dynamic and table driven, that’s a bit harder. Maybe add new data tables into the app, and use the Intersect() function to combine them? E.g. a table with values for non-admins, and a second table with values for admins, etc.

1 Like

Thanks Ty and Austin – very helpful, that did it. (It’s not a dynamic list so that makes it simpler)

1 Like

One more question. I just attempted to set the “Special Val A” (one of the Admin only values) and I got this error message: "Value ‘Booked’ in field ‘Referral Status’ cannot be converted to type Enum. https://share.getcloudapp.com/2Nu5jDNO

Here’s a screenshot of the field setup:
Shared with CloudApp
Shared with CloudApp

Try to “turn on” - Allow other value in enum type field.

2 Likes

Thank you for the suggestion. My concern with your suggestion is I do not want users to be able to add their own values to this field.

Why dont you just make 2 fields/Columns for this input. And make it visible only if user is admin. Make one with users values and one with admin values.