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 445
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