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.

0 9 456
9 REPLIES 9

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.

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

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.

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

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

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

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.

Top Labels in this Space