You are here:
Context Filters with Custom Filter Logic
Retrieve precise, relevant, and dynamic data from your context definitions. Customize filters for your context definitions without modifying code.
Required Editions
| Available in: Lightning Experience |
| Available in: Developer, Enterprise, Professional, and Unlimited editions for Industries clouds where Context Service is enabled |
Combine context filter conditions with custom logic instead of a single AND or OR across conditions for context nodes. Reference numbered filter condition rows in an expression such as 1 AND (2 OR 3) to retrieve precise and relevant data. Custom filter logic matches the filtering pattern that you already use in Salesforce reports and list views.
What Custom Filter Logic Does
With custom filter logic, you choose how node conditions combine using these operators:
- AND: All conditions must be true.
- OR: Any condition can be true.
- Custom Filter Logic: Provide an expression that references each condition by its row number and combines them with the AND and OR operators and parentheses, such as 1 AND (2 OR 3).
Why Use Custom Filter Logic
Real-world filtering often needs more than a single AND or OR across all conditions. Custom filter logic lets you group conditions and mix operators.
Custom Filter Logic Rules
- AND binds tighter than OR. For example, 1 AND 2 OR 3 evaluates as (1 AND 2) OR 3.
- Every row number in the expression must reference an existing condition.
- Group conditions to control evaluation order. You combine row numbers with the AND and OR operators and group them with parentheses. Parentheses must be balanced, and each pair must contain a valid sub-expression.
- The NOT and XOR operators aren't supported.
- Spaces are optional between elements.
- The expression that you type is preserved exactly as entered, including parentheses, when you edit or clone the filter.
Considerations
- A context filter supports up to five filter conditions across nodes and up to two sort orders for a context definition.
- The expression references row numbers, not condition IDs.
- The expression is validated when you save the filter.
- When you delete a condition, the remaining rows renumber to fill the gap, but your expression text stays the same. If the expression now references a row that no longer exists, you see a validation error when you save. Update the expression to reference the correct rows.
- An empty expression causes an error when you save.
- Create a Context Filter with Custom Filter Logic
Filter and sort your contextual data with Context Filters. Build a context filter that combines conditions with a custom expression. Define your conditions, switch the filter to custom logic, and enter an expression that references each condition by its row number. - View, Edit, Clone, Delete a Context Filter
View filter conditions and sort order details of a filter in a standard context definition. Edit or clone filters from a custom context definition to iterate over existing filter conditions and sort order details. Delete unnecessary filters from the Filter list in your customer context definition.
