Filter Element

Filter Icon With the filter step we can filter out recommendations from a branch based on characteristics of the recommendations and information from the context object or user information. The filter is placed in a branch. So all the recommendations that are loaded in that branch will get evaluated and the ones that don’t apply to the filter settings will be removed. For example, if you have a branch containing 5 recommendations then after the filter step you could be left with anything between 0-5 recommendations.

Going back to our previous example, if we add a filter that checks if there is a 2 in the name:

Filter Screenshot

Then the strategy looks like this:

Filter Screenshot

And the outcome is that only recommendation 2 is shown:

Filter Screenshot

Obviously, this isn’t the best example, because why did you load the recommendation in the first place if you are going to filter it out like this again. The real use case comes from basing the filter on the context for the strategy. Given that Recommendation is just a normal object we can also make extensions to this. I’ve extended the Recommendation object with a Category text field. This field I use to specify for which Case status I want to show the recommendation. The recommendations then could look like this:

Filter Screenshot

Now we are going to look at context data, so for that you need to make sure you’ve linked the strategy to a certain object:

Filter Screenshot

Once you’ve linked a strategy like this to an object and you place the Recommendations component on the Case detail page then you get access to the active case record through the variable $Record. Filtering on the fact that the category needs to match the status of the case will look like this in the Filter definition:

Filter Screenshot

Keep in mind that the filter expression is evaluated per Recommendation on the input branch. For each recommendation it will check if the Status of the Case equals the Category field on the Recommendation, and all Recommendations that apply will continue after the Filter.

Back to Elements

1452 reads