Action Behavior show_if formula help

Hi,

I am looking for assistance building an action that is only available to app users that have a specific user type in my Users table.

I am able to do this by who is logged in and using the app:
OR (
USEREMAIL() = "useremail-1@xxx.com",
USEREMAIL() = "useremail-2@xxx.com"
)

It would be a better situation to use data from my User table instead:
USER[user_type] = "Reviewer"

I can't seem to get this to work correctly though. I think one of the problems is that the Table I am attaching the action to does not have a user_id column in the table.  Thank you in advance.

Solved Solved
0 16 915
3 ACCEPTED SOLUTIONS

Try this:

ANY(SELECT(User[user_type],[user_id]=USEREMAIL()))   =   "Reviewer"

 ANY(SELECT(User[user_type],[user_id]=USEREMAIL())):
Returns the value in the User Type column of the record of the user who is currently logged in to the AppSheet instance this expression is running on.

Its taking that value and if it's equal to "Reviewer" then its true and the action will show, if the ANY(SELECT()) returns a User Type other than "Reviewer" it will return FALSE which will hide the action.

 

I personally use ANY(SELECT())s over Lookups almost every single time, I suggest using the one which syntaxes you feel more comfortable using.

View solution in original post

For sure Good luck with the rest of your App!

One last thing, considering that specific scenario, it's possible that you might require the capability to grant access or display certain columns to multiple user types in the future. This can be achieved like this:

IN( ANY(SELECT(User[user_type],[user_id]=USEREMAIL()))   ,   LIST( "Reviewer" , "Admin" ) )

In this instance, if the current user's user_type is either "Reviewer" or "Admin," they would be able to view the specified action.

 

During my consulting calls nearly every client utilizing the [role]="...." approach eventually  requires this expression as well.

View solution in original post

Either of these should work:

IN( [request_status] , LIST( "Pending" , "Reviewed" )  )
OR(
[request_status] = "Pending"),
[request_status] = "Reviewed")
)

 

View solution in original post

16 REPLIES 16
Top Labels in this Space