How to use the 'Filter based on transformer' filter

Table of contents

  • Use case
  • Guide

Use case

The “Filter based on a transformer” filter allows users to execute a transformer, for example, to load external data from an API, before running the comparator.


Here’s how you can implement the transformer.

Step 1: Click on Add Data Transformer.

Step 2: Select the ‘Filter Based on Transformer’ filter.

Step 3: Add Data transformer which will be filtered and set it up.

Step 4: Select Comparator which will filter out entities based on the configured comparison. There can be different options such as Equals/Doesn’t equal, Greater or Less than etc. This means the main Comparator function is to define in which way entities in the transformer should be filtered out.

Step 5: Add Entity Path where the transformer should find entities.

Step 6: Add Search Pattern based on which transformer will find the pattern and filter it due to the selected Comparator.

The transformer can be executed with or without the available entity data as input based on the “Use entity data in transformer” checkbox.

Note: If the filter is added to the Incoming or Route configuration, it allows filtering out entities and no tasks will be created for the entity. When added to the outgoing configuration the task status will be set to Skipped and the publisher will not be executed.

Example of Configuration

In this example, we are going to check whether the specific date expired or not
based on a date comparison.

  • Select settings → Data, transform data using mappers and conditions → Conditional transformer → And then put “filter based on transformer” in it as the “if” part.

  • Select data transformer → value setter → fill in the fields in the configurations as the example below:
    - Key = today
    - Value = string leave field on the right side empty
    - Mappers = Format:Date
    - Output = Y-m-d

  • Select comparator → Pick “Greater than” → fill in the “Search pattern” as the first input. The “Search pattern” must be based on the configuration key which was previously filled in as “today” → Fill in the “entity path” as the second one - let’s say “expired_date” → Make sure the “Use entity data in transformer” checked.
    This way we apply a logic

     if(today > expired_date) // if search pattern greater than entity path

  • Configure the “then” part in the “Then apply transformer” → select value setter → fill in the key as let’s say “is_expired” → set the value as a boolean cause we need to store the date comparison result.

  • Last but not least we set the apply transformer to see the result “is_expired”

To test the transformer we give this object as an input:

  "expired_date": "2024-10-01"

Here is the result:

The example of configuration can be downloaded here:

filter-based-transformer-comparing-the-date_transformer.ndjson (921 Bytes)