Query filters allow you to restrict which data from a case store certain users will be able to access. They can be written to apply a filter expression to environment groups of users who query the case store and only allow those users to see certain records. When combined with user profile fields they can also be used to filter queried content at a user level, with no environment group assignment required.
See:
- Using a filter expression and an environment group
- Using a filter expression with user profile fields
- Using multiple query filters
Using a filter expression and an environment group
To add a new Query Filter, click New.
For example, consider a data set that contains a state field containing values from all 50 United States (IL, CA, OK, and so on). Also, suppose that a system environment group named "Midwest" already exists, containing users who are only supposed to work with data from the Midwest U.S. region.
To construct a Query Filter that would only allow users in the "Midwest" environment group to see data from Midwest states, we could write the following Filter Expression:
state = 'IL' || state = 'IA' || state = 'WI'
You could add more states if they needed to be considered part of the Midwest U.S. region.
We would then need to select the Midwest environment group as the environment group to apply this query filter to. By default, this query filter would then only allow users in the Midwest environment group to see data from IL, IA, and WI. Importantly, users not in the Midwest environment group would not see anything.
Once a query filter with an environment group assignment is applied, the default behavior is that users who are not part of that environment group will see no data when they query the case store. To reverse this behavior, select Allow user to view all data when there are query filters but no matching query filter is found for a user, allowing users who are not part of the query filter's environment group to see all data in the case store.
Using a filter expression with user profile fields
As an alternative to applying query filters at an environment group level, query filters can be combined with user profile fields to apply restrictions at an individual user level.
For example, consider a scenario where the following user profile fields have already been set up on the following user accounts:
User account |
Profile field name |
Profile field values |
---|---|---|
Bob |
state |
IL,MA |
Jane |
state |
CA |
In this scenario, a query filter with the following Filter Expression could be used:
caseStoreStateField = PROFILE_FIELD('state')
Here, 'state'
refers to the profile field name set on the user account and caseStoreStateField
refers to a state
field in the case store containing values from all 50 U.S. states. When a user queries the case store, the query
filter will then only show them records where one of their Profile Field
values matches the caseStoreStateField
value. With this type of set up, no environment group assignment is required.
Using multiple query filters
When multiple query filters are applied, the query filters are treated in an OR-like fashion. That is, each query filter is considered independently.
For example, if you had the following expressions being used as query filters:
- field1 > 0
- field2 < 100
Values such as -1 or 101 would both make it through the query filters.
To get an AND effect, you would need to combine these expressions into a single query filter.