Conditional Permissions
Conditional Permissions are configured as part of the Object Class Permissions. Object Class Permissions serve as the maximum permission a given Role may have towards a given Object Class (create, read, update or delete). With Conditional Permissions, you may grant conditional access for different Roles to different Object Classes, and it is an important concept when defining data silos for a multi-tenant application.
As with normal Object Class Permissions, the Conditional Permissions are enforced server side (back end) and are tamper-proof as opposed to hiding data or UI using conditions inside your App.
The Role End Users have Read and Update permissions towards the Person Object Class, for users to update their own Person object from a view in an App.
However, on a permissions level on the back end, all End Users have access to all Person objects - not only their own record/object. Without Conditional Permissions, you must be very strict with filters and what data to load into your App.
With Conditional Permission, you may set up a rule that is enabled for End Users, only allowing you to read and update your own Person object.
Setup Guide
This is a short guide on how to set up Conditional Permissions given a specific use case.
Use Case
Consider the following Data Model

A logged-in User has an Person object. A Person belongs to a Company and may have a set of Person Documents. A Company may have a set of Orders.
We want to make sure
The user only has read access to the
Personobject (the one connected to the Current User) and the belongingPerson DocumentsThe user only has access to the connected
Companyand the belongingOrders
Configuration
For configuration of Conditional Permissions, go to Security -> Permissions -> Object Classes.

Once an Object Class has a Create filter, hover its row to show a duplicate button after the Aggregate filter (tooltip Duplicate Create filter to undefined operation filters for Object Class). It copies the Create filter to the operations that have no filter yet.
Read-permissions on the Person Object Class
Clicking the Filter icon for the Person Object Class in the above screenshot opens a dialog for configuring the conditional Read-permissions for the Person Object Class.

Name: Optional, this is just a describing name for the rule
Enabled: This is where you set the condition on when this rule should apply. In this example, this rule should only apply when the logged-in user has the Role
End userFilter: The filter that always should be applied when reading Persons (when Enabled is true). In this case, always apply the filter
Person.User = Current User. If a rule has no filter and Allow all is not selected, the rule gives access to no objects.Allow all: Gives access to all objects when Enabled is true, instead of defining a filter. Only available when Filter is empty.
Note that when Read permission has been set up conditionally for a given Role (or Roles), and some other Roles should have access to all, we need to add a rule for that as well, with Allow all selected. In the below screenshot, any user with a membership in any of the Roles Owner, Maintainer or Developers has read access to all Persons.

In other words: With Conditional Permissions set up, a user will get the sum of permissions defined by the rules in the setup above. If a user is both a Maintainer and an End User, the user will have read access to all Persons.
Read-permissions on the Person Documents Object Class
The same Enabled conditions and set of rules apply to this Object Class. But the Filter is different.


We need to define the path from Person Document to Current User, for the Read-permissions to work. The above screenshots illustrate how to set up a filter on all Person Documents belonging to a Person that the Current User is connected to.
Read permissions on the Company Object Class
For these permissions, we need to define a filter on all Companies belonging to the Person that the Current User is connected to.

In the above screenshot, the Person Object Class has the following filter:

Read permissions on the Order Object Class
For these permissions, we need to define a filter for all Orders belonging to the Companies of the Person object that the Current User is connected to. It is the same setup as for the Company permissions, except the left side of the filter (where Order.Company is the property we are filtering on).


Performance considerations
Conditional Permissions filters are evaluated server-side on every read of the affected Object Class. The more work a filter does, the more work the back end does on each read.
A Conditional Permission is a security boundary, not a Data Source filter
Conditional Permissions are enforced inside Appfarm's server-side data layer — they are not applied as a filter on your App's own query. That is exactly what makes them tamper-proof: objects a rule excludes are never sent to the client, whatever the App asks for. But it also means that a rule does not make a wide read cheap.
A Data Source with Read all on a conditionally protected Object Class still asks for the entire Object Class. The back end reads it, evaluates the rule for the current user across it, and returns only the objects that survive. The App ends up with a small data set, while the back end has done the full amount of work — for every user, on every App load.
Keep filters flat and few-claused
Two patterns are the most common causes of slow data loading:
Filters that traverse nested properties (deep data bindings), such as
Order.Company.Owner.Department = .... Each step in the path adds a join to the underlying query.Filters with many clauses, especially when several of them traverse nested properties or reference other Object Classes.
In combination with large data volumes, these patterns can produce heavy database queries and noticeable lag when the App loads data or when filtered Data Sources refresh.
For broader guidance on diagnosing and resolving slow data loading, see Optimize performance.
Limitations
Conditional Permissions are powerful, but there are a few limits to keep in mind when designing your rules.
What a rule filter can express
A Conditional Permission rule applies a filter that is evaluated server-side on every read. A filter can compare:
the Object Class's own properties, and
single-step (one-hop) references — for example
Person.Company = ....
A filter cannot express:
"Exists in" sub-queries against another Object Class — for example, "grant access if a separate sharing record links this object to the current user", or
Multi-hop traversal from the object on the right-hand side of a comparison — for example, after matching a multi-reference with
Order.Companies has some of Person (filtered), you cannot then traversePerson (filtered).Company.
Deep nested traversal on the left-hand path (for example Order.Company.Owner.Department = ...) is supported, but each step adds a database join. See Performance considerations.
Rules restrict, never expand
Object Class Permissions define the maximum access a Role can have. Conditional Permissions only narrow that access — they can never grant a Role access it doesn't already have. Because a user receives the sum of all matching rules, remember to add an explicit rule with Allow all for Roles that should see everything (such as Owner, Maintainer and Developers) when you restrict Read for other Roles.
Subscribe to Updates
If an Object Class has conditional Read-permissions, "Initially Subscribe to Updates" will not work for Data Sources of that Object Class. Conditionally-protected data cannot be broadcast to subscribers, because the platform cannot determine in advance which recipients are allowed to read each object. See Data sources.
Last updated
Was this helpful?