You are here:
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.
Required Editions
| Available in: Lightning Experience |
| Available in: Developer, Enterprise, Professional, and Unlimited editions for Industries clouds where Context Service is enabled |
| User Permissions Needed | |
|---|---|
| To create context filters: | Context Service Admin |
- In Setup, find and select Context Definitions.
- On the Custom Definitions tab, select the context definition that you want to add a filter to.
- Click the Filters tab.
- To create a context filter, click New Filter.
-
Enter the Filter Name, API Name, and
Description.
Document the intent of a complex expression in the filter's Description field so that others understand the logic.
-
In the Conditions section, define conditions for nodes.
-
Click Add Node and select a node from the list of available
nodes.
You can add multiple nodes and the logical condition between nodes is always AND.
-
To add a condition for the node, click Add Condition.
You can add up to five conditions across nodes. The row number for each condition appears automatically on the left.
- Select the Attribute and Operator, and enter a Value.
- To set the logical condition for attributes within a node, select the operator at the node level. It can be AND, OR, or Custom Logic.
- (Optional) To define custom filter logic between attributes, select Custom Logic and in the Filter Logic field, enter an expression for the node. The expression must reference condition row numbers and combine them with AND, OR, and parentheses. For example, 1 AND (2 OR 3) means condition 1 must be true, and either condition 2 or condition 3 must be true.
- (Optional) To sort the data, in the Sort Order section, select a Node, Attribute, and Sort Order, and if needed enter a Limit value. You can add up to two sort orders for the definition.
-
Click Add Node and select a node from the list of available
nodes.
- Save your changes.
The filter is saved and the context definition data is hydrated based on the applied filters.
Example
| Goal | Conditions | Expression | Meaning |
|---|---|---|---|
| Simple AND | Row 1: Status = Active; Row 2: Amount > 1,000 | 1 AND 2 | Status is Active and Amount is greater than 1,000. |
| Simple OR | Row 1: Tier = Gold; Row 2: Tier = Platinum | 1 OR 2 | Tier is Gold or Platinum. |
| Nested logic | Row 1: Status = Active; Row 2: Amount > 1,000; Row 3: Tier = Platinum | 1 AND (2 OR 3) | Status is Active, and either Amount is greater than 1,000 or Tier is Platinum. |
| Grouped on both sides | Row 1: Region = West; Row 2: Region = East; Row 3: Revenue > 100,000; Row 4: Account Type = Enterprise | (1 OR 2) AND (3 OR 4) | Region is West or East, and either Revenue is greater than 100,000 or Account Type is Enterprise. |
Questo articolo ha risolto il problema?
Facci sapere, così possiamo migliorare!
