Resultsets

Resultsets are groups of fields that have a filter applied to them. This makes them ideal for situations in which you only want to show a subset of all items.

Concept

Here's how you use resultsets in Smart Flows:

  1. Add a new resultset.
  2. Choose which fields to include in the resultset.
  3. Define conditions to use as a filter.
  4. Loop over the resultset.
  5. Map fields inside the loop.

Now only the fields that adhere to the conditions are looped over, giving you a filtered list of items.

For instance, you can use a resultset to filter out the marketing contacts from of a list of all contacts:

Configuring resultsets

Creating a resultset

To create a resultset, follow these steps:

1. In the pane, select the Add resultset button:

2. Give your resultset a name that makes sense. We'll be making a resultset that contains all the blue products.

3. Choose the field on which to base the resultset, by clicking the field button next to base field. All the child elements of this field will be included in the resultset.

4. Select the New Condition button.

5. A window opens where you define the new condition. You can choose to check whether a field has a specific value, or whether an expression has a specific value:

6. After choosing, select the field or expression button to choose a field or define an expression for use in the condition.

This page explains how to use expressions.

7. Next, choose how to use the field: as a text, number or date. The comparison options change depending on how you wish to use the field.

8. Then, choose how to compare your field:

9. Finally, type in a value (or select a value with the field button, or a date with the date button in case your type is a date). Our type field contains the text Blue products, Red products or Green products, and we only want the blue products, so we type in blue products. It's not case-sensitive.

10. Select OK to see your condition in the resultset's condition list. Select OK to close the resultset window.

You'll now see your resultset, and all of the underlying fields, in a separate part of your data set:

Editing a resultset

You can change your resultset after you've created it. To do that, select the resultset in the data set tab of the pane and select Edit.

This brings up the resultset window again, where you can change the settings.

Adding further conditions

It is possible to add multiple conditions to the same resultset. This allows you to create complex filters.

When using multiple conditions in a resultset, you need to define how they behave in relation to each other. This is done by grouping them in a condition group.

There are two types of condition groups:

  • In an AND group, every condition must be met in order for the group condition to be met. For instance, the following picture shows an AND group that requires that every product is a marker and that it needs to be restocked:
  • In an OR group, at least one condition must be met in order for the group condition to be met. For instance, the following picture shows an OR group that combines all markers and paperclips:

To add another condition to your resultset after you've created it, follow these steps:

1. Open your resultset again by selecting it and clicking Edit in the data set tab of the pane.
2. Select the New Condition button to add another condition.

3. Set the condition according to your liking. In our case, we've decided to refine our resultset further by not just including the blue products, but the blue products that are more expensive than €25.

4. Now the second condition has been added. The two conditions now have to be grouped in an OR or an AND group. If you leave them, the default behavior is AND.
5. To create a group, select the conditions or groups you want in the group by checking the boxes and clicking Group AND or Group OR.

6. This will add them in a group, which is visualized as such:

7. You can then add even more conditions and group them further.

8. If you want to remove a group, select the group (don't check the box, you have to select the name) and select Ungroup:

9. You can also change a group from OR to AND or vice versa by selecting the group and clicking the Change to button:

10. To remove a condition, select it (select the name, don't check the box) and select Delete.

11. Once you're happy with your resultset's conditions, select OK to save it.

Using resultsets

Now that the resultset is fully configured, you can use it in your template. This implies that you use your resultset in a loop. Unlike a regular loop, you won't be looping over a field, but over a resultset. The difference is that the fields inside the loop will only be shown if, for that iteration, the conditions of the resultset are true.

Follow these steps:

1. Select the zone you want to loop over.

2. Select your resultset and select Loop.

3. This inserts a loop over the resultset. Note that this loop is just a regular loop, so you can go into the loop's settings for additional options, such as sorting the loop.
4. It's likely that you'll want to include fields from the resultset in the loop, so let's map a few:

5. Clicking preview shows us the products inside the resultset, which are the blue products that are more expensive than €50:

To verify that this works, let's make the same loop - but this time, over all products, not just the resultset:

As you see, there are only 2 blue products that are more expensive than €25, so that worked nicely!

Note that you can map either the field from inside the resultset or the field from the data set - it doesn't make a difference.

Considerations

Adjusting the field path

When using expressions in resultsets, you need to adjust the field path. Using the full path (like in normal expressions) won't work in a resultset, so you need to adjust the path so that it is relative to the resultset's base field. An example will make this clear:

This is our data set, with the base field highlighted:

Now, we want to use an expression to check whether the Name field starts with the letter a. We define the expression like this:

But this won't work, since you need to define your field paths relative to the base field in expressions in resultsets. Instead, you define your field like this:

You just remove the part that comes before (and includes the) base field and replace it with a dot.