Permisiones Según Rol

 

Hello everyone. Today I want to consult about how I can create a formula to allow the modification of the tables according to the user's role.

I would not like it to be universal but rather that the user type Admin, modify and add but the User cannot do more than what I allow.

I know what is done from the "Table" section but I don't know how to apply the formula.

IF(USERROLE()="Admin",AND("Updates","Add","Delete","Read-Only"),"Updates")

This is something untested. But well I expose what I wanted to do.

Greetings Thank you.

Solved Solved
0 3 109
1 ACCEPTED SOLUTION

The issue in your expression is how you're using the AND function. That function returns a true/false value--not a list of values. Regardless, in this case, you need to return only a single value.

See, for example, the following sample expression from the USERROLE help article:

IF((USERROLE() = "Admin"), "ALL_CHANGES", "UPDATES_ONLY")

You can reference the list of valid permission enum values when you open the expression editor for a table's Are updates allowed? property:

  • An expression to dynamically change the update mode of the table on a per-user basis. The allowed values are "READ_ONLY", "UPDATES_ONLY", "ADDS_ONLY", "ADDS_AND_UPDATES", "DELETES_ONLY", "UPDATES_AND_DELETES", "ADDS_AND_DELETES", and "ALL_CHANGES" (Enum)
    dbaum_0-1656770871350.png

 

View solution in original post

3 REPLIES 3

The easiest way if your app requires user sign-in (Security > Require Sign-In > Require user signin? = ON) and you know who is who (from each user's email), then use something like the following expression in table's "Are updates allowed?" entry.

SWITCH(USEREMAIL(),
   "you@gmail.com", "ALL_CHANGES",
   "admin@gmail.com", "ALL_CHANGES",
   "operator1@gmail.com", "UPDATES_ONLY",
   "operator2@gmail.com", "ADDS_ONLY",
   "operator3@gmail.com", "ADDS_AND_UPDATES",
   "operator4@gmail.com", "DELETES_ONLY",
   "operator5@gmail.com", "UPDATES_AND_DELETES",
   "operator6@gmail.com", "ADDS_AND_DELETES",
   "READ_ONLY"
)

The issue in your expression is how you're using the AND function. That function returns a true/false value--not a list of values. Regardless, in this case, you need to return only a single value.

See, for example, the following sample expression from the USERROLE help article:

IF((USERROLE() = "Admin"), "ALL_CHANGES", "UPDATES_ONLY")

You can reference the list of valid permission enum values when you open the expression editor for a table's Are updates allowed? property:

  • An expression to dynamically change the update mode of the table on a per-user basis. The allowed values are "READ_ONLY", "UPDATES_ONLY", "ADDS_ONLY", "ADDS_AND_UPDATES", "DELETES_ONLY", "UPDATES_AND_DELETES", "ADDS_AND_DELETES", and "ALL_CHANGES" (Enum)
    dbaum_0-1656770871350.png

 

Thank you very much @dbaum have a good day!

Top Labels in this Space