combine expressions

Hi, I want to combine two expressions in table settings: if more than a day has passed, only admins can make changes. I have this two formulas:

(NOW() < ([DATO DE TIEMPO] + "024:00:00"))

SWITCH(
LOOKUP(USEREMAIL(), Usuarios, UsuarioMail, UsuarioRol),
"ADMIN", "ALL_CHANGES",
"READ_ONLY"
)

haw can I combine them? thank you very much

Solved Solved
0 12 317
1 ACCEPTED SOLUTION

Ah. I apologize--I didn't consider your problem well enough. You're going to have to take a different approach.

The Are updates allowed? setting for a table applies to the table as a whole: if the setting gives a user ALL_CHANGES access, that user has ALL_CHANGES access to all rows. This setting cannot be used to control access to individual rows selectively.You appear to want to control access to individual rows selectively.

To control access to rows selectively, you need to use the Only if this condition is true setting for the appropriate actions for the table:

Steve_0-1675719896134.png

An expression suitable for your needs based on the info you've provided might be:

OR(
  (NOW() < ([DATO DE TIEMPO] + "024:00:00")),
  ("ADMIN" = LOOKUP(USEREMAIL(), "Usuarios", "UsuarioMail", "UsuarioRol"))
)

You'll need to consider whether you should configure this for each individual action the user may have access to, notably AddDelete, and Edit.

View solution in original post

12 REPLIES 12

Steve
Platinum 4
Platinum 4

Thanks Steve! but I couldn't build it. 

Condition AND((NOW() < ([DATO DE TIEMPO]+"1.00:00:00")), SWITCH(ANY(SELECT(Usuarios[UsuarioRol],([UsuarioMail] = USEREMAIL()))),"ADMIN","ALL_CHANGES","READ_ONLY")) has an invalid structure: subexpressions must be Yes/No conditions

I thought it better as an if expression like that

IF (
(NOW() < ([DATO DE TIEMPO] + "024:00:00")),

(SWITCH(
LOOKUP(USEREMAIL(), Usuarios, UsuarioMail, UsuarioRol),
"ADMIN", "ALL_CHANGES",
"READ_ONLY"),

("ALL_CHANGES")
)

but this is the sistem answer: IF function is used incorrectly:three inputs should be provided --- (condition, if-result, else-result).

I am lost =(

Ah. I apologize--I didn't consider your problem well enough. You're going to have to take a different approach.

The Are updates allowed? setting for a table applies to the table as a whole: if the setting gives a user ALL_CHANGES access, that user has ALL_CHANGES access to all rows. This setting cannot be used to control access to individual rows selectively.You appear to want to control access to individual rows selectively.

To control access to rows selectively, you need to use the Only if this condition is true setting for the appropriate actions for the table:

Steve_0-1675719896134.png

An expression suitable for your needs based on the info you've provided might be:

OR(
  (NOW() < ([DATO DE TIEMPO] + "024:00:00")),
  ("ADMIN" = LOOKUP(USEREMAIL(), "Usuarios", "UsuarioMail", "UsuarioRol"))
)

You'll need to consider whether you should configure this for each individual action the user may have access to, notably AddDelete, and Edit.

wonderful Steve! it worked perfect y the actions edit and delet!

but in the action add, it doesn't work, it eliminates the add botom even today...

since you are so kind, could you help me with that?

thank you very much!!

 

Add action can't access column values (how could it, if the record isn't even created yet?), so you'd only need to use the "Admin"= condition for that one.

yes Marc, you are right. what I want is that users who are not admin, can not add rows whith Date before today

What @Marc_Dillon means is that the Only if this condition is true expression for the Add action should be this:

("ADMIN" = LOOKUP(USEREMAIL(), "Usuarios", "UsuarioMail", "UsuarioRol"))

in this situation the other users can not add rows today. I've just posted below my solution. than you very much!

EDIT: ahh, nevermind, you already did ๐Ÿ˜„

You would also need to specify a valid_if for this requirement.

https://help.appsheet.com/en/articles/961211-valid_if-column-constraint

Check the number of parentheses. It looks like you have some extra parentheses that are closing off the expression before the end of the IF() clause.

thank you Elik but they are checked and the error seems to be another

I think I've allready solved it whith this formula in the column DATE in valid_if:

OR ([FECHA] >= TODAY(), "ADMIN" = LOOKUP(USEREMAIL(), "Usuarios", "UsuarioMail", "UsuarioRol"))

so only admins can add rows with previous dates!

Thanks very much to all of you!!

Top Labels in this Space