hello friends,
I am trying to set my [contracts] table so that only users with specific roles can edit the data. The expression I am trying to use for the condition for the edit action button is:
switch(any(current user[Position]),
"super admin","true",
"admin","true",
"director","true",
"supervisor", [Creator] = useremail(),
"false")
However, whenever I update that, it does not work. The specific error I get is:
The availability condition '=switch(any(current user[Position]), "super admin","yes", "admin","yes", "director","yes", "supervisor", [Creator] = useremail(), "no")' of data action 'Edit' must return true or false
(I have tried this with yes/no and true/false)
It seems to be something particular to the switch statement that is causing trouble. The following statement works just fine:
in(any(current user[Position]),list("super admin", "admin","director","supervisor"))
and so does this:
[Creator] = useremail()
From my understanding, my switch() statement should result in true or false statements for each row. If anyone has any advice please let me know.
Thanks,
Rob
Solved! Go to Solution.
I am not at my desk to test. But my one request will be to test without double quotes for TRUE and FALSE in the expression the way I have suggested.
Typically double quotes convert a text to text strings
I have got my original logic working with a different expression:
if(any(current user[Position]) = "supervisor",[Creator] = useremail(),
in(any(current user[Position]),list("super admin", "admin","director",))
)
Howwever how I understand the logic this should work the same as my switch() statement
It sounds that in the SWITCH() statement , for the position "supervisor", there is no evaluation of TRUE or FALSE, the resulting condition is missing. Also [Creator] = useremail() appears to be out of place in the SWITCH() expression because it does not relate to the sub expression, any(current user[Position]) that SWITCH() is evaluating.
switch(any(current user[Position]),
"super admin","true",
"admin","true",
"director","true",
"supervisor", [Creator] = useremail(),
"false")
Not tested, but you could try the following
OR(
SWITCH(ANY(current user[Position]),
"super admin", TRUE,
"admin",TRUE,
"director",TRUE,
"supervisor", TRUE,
FALSE),
[Creator] = USEREMAIL()
)
Thanks Suvrutt, however even if I switch the formula to not including the supervisor condition, it still doesn't work. this code:
switch(any(current user[Position]),
"super admin","true",
"admin","true",
"director","true",
"supervisor", "true",
"false")
still throws the error:
The availability condition '=switch(any(current user[Position]), "super admin","true", "admin","true", "director","true", "supervisor", "true", "false")' of data action 'Edit' must return true or false
I have got the expression working using an if formula:
if(any(current user[Position]) = "supervisor",[Creator] = useremail(),
in(any(current user[Position]),list("super admin", "admin","director",))
)
So I am good, but if anyone can enlighten why the switch() isn't working I would appreciate it ๐
I am not at my desk to test. But my one request will be to test without double quotes for TRUE and FALSE in the expression the way I have suggested.
Typically double quotes convert a text to text strings
Welp that was it. Really thought I tested that. Thanks a bunch
You are welcome.
User | Count |
---|---|
43 | |
30 | |
26 | |
14 | |
14 |