We are currently working on a project with multiple user types and want to apply rules to our collections to ensure correct access.
While writing the rules we encountered an issue. Rules that contain more than one statement in the apply_when are just not working and just throwing exceptions in backend:
error executing match expression: invalid document: must either be a boolean expression or a literal document
(With “company” being a field in the document and “supplier” beeing a possible value of the type in the custom data)
Both statements of the apply_when are working solo in other places. But when together - they result into the exception.
Are we missing something? Because in the documentation this is presented as the way to go for multiple statements.
hi
I had a problem like this , i just found the solution
I think the problem is with “company” field.try this:
1-convert rules to advanced rule
2-leave apply_when field empty
3-for read ,write, search,insert field copy and paste your original condition
4-for delete field use this line of code:
I broke my head about this too. But I found a way to do this, indeed the documentation lacks information on this.
A bit of a late reply, but hopefully others will get something out of it.
Add a %and around your 2 requirements.
In this example, a role is assigned if one of the user’s groups appears in the “access.owner” array + if it has a “pro” license.