Record-Security Rules/Expressions

Hi! I was trying to make a security rule for my record (filter --> loggedUserName() = nomProveedor (one of my fields)), but in the security rule I can only put direct values or constants

 

I found out that there are security expressions, but how should be my structure to obtain a filter like the mentioned one? Example:

Username: Proveedor 1

I want to filter the record so that he can only see the rows in which my field "nomProveedor" is equal to the Username

Thanks a lot!

  Discussion posts and replies are publicly visible

Parents Reply
  • Thanks! I´m trying with this expression (I also searched in appian documentation). It works properly when I sign with an account of the group "CPF Proveedores", showing filtered values based on my username. But when I sign with another account out of the group, I obtain the null value and I can´t see the record. I think I should change the operator: "is null", for something that indicates that no filter should be used there but I want the values to be shown.  What can I do?

Children
  • 0
    Certified Lead Developer
    in reply to carlosp5114

    Hi carlos, 

    Use an error message banner in the interface which will have the same showWhen condition as your security rule. Then, for the current record security rule, display all the values when the user is not in the group. The result of this would be: 

    • You will display all the records if the user is not in the group
    • The banner message will be shown if he is not in the group. 
       
  • Several issues here.

    The logic in your and() statement, namely the second line, is nonsensical to Appian.  The not() rule returns the opposite value of a boolean value exclusively - but "nomProveedor" is NOT a boolean value.  Additionally the value you have inside the "not()" is a reference to a record field, not a reference to a value, which i presume you want.  So to fix this, you'll need to change this line completely so that it actually returns a meaningful value to the parent logic.

    Additionally I don't believe you can apply logic here that invokes the value in a field of a specific row of the record (like you seem to want to be doing on line 4).

    If we take out line 4 altogether, for example, then the current filtering logic translated into plain language would basically be,

    "If the viewer is a member of CPF Proveedores, then only allow them to see record entries where nomProveedor is NULL.  Otherwise, only allow them to see record entries where nomProveedor equals their username."

    What else still needs to be different?

  • Thanks a lot! I changed the expression and searched in the docummentation and know it works properly!

  • Ok sweet - thanks for confirming.  If/when you get a chance it'd be nice if you could also click "verify" on my helpful answer(s) here Slight smile

    Thanks a lot! I changed the expression and searched in the docummentation and know it works properly!