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
  • 0
    Certified Lead Developer

    I assume you will need to choose this option instead.

  • Thank you so much. How would be the ideal structure to make a filter expression to obtain my desired output?

  • 0
    Certified Lead Developer
    in reply to carlosp5114

    As it says on that page, you need to use a!queryFilter (or a set of query filters joined together under a!queryLogicalExpression) - the simplest being configured along the lines of:

    a!queryFilter(
      field: recordType!myrecordtype[record type field reference],
      operator: "=",
      value: tostring(loggedInUser())
    )

  • 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?

  • 0
    Certified Associate 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. 
       
  • 0
    Certified Lead Developer
    in reply to carlosp5114

    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?

Reply
  • 0
    Certified Lead Developer
    in reply to carlosp5114

    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?

Children