Skip to Content

Filter records using conditions in Jitterbit Studio

Introduction

A common use case for using conditions in a transformation is as a filter to determine if a record (or part of a record) should be processed or skipped.

When to use conditions

Conditions can be thought of like the WHERE clause in a SQL statement.

Conditions are typically built using scripting. The output of a condition is either true or false.

Since transformations execute from the top of the target transformation down, frequently the condition of the top node is used for actions not specific to any single data node, nor related to the determination of processing or skipping the record.

Such general-purposes tasks include these:

  • Setting variables
  • Performing lookups
  • Updating record counts
  • Logging values

If the condition node is used in this way, take care to ensure that all records are processed, such as simply putting true as the last line in the script.

Conditions can be set not only at the topmost node, but also at subnodes, meaning that just that section would be skipped or processed.

Example conditions

The following examples show typical condition scripts. Each script must return true to process the record or false to skip it.

  • Filter by field value:

    // Process only records where the status is "active"
    If($source_status == "active", true, false);
    
  • Filter using a dictionary lookup (skip records whose key is not in a pre-populated dictionary):

    // Only process records whose ID was found in the source query
    If(HasKey($dict.valid_ids, $source_id), true, false);
    
  • Filter out records already processed in this run (deduplication):

    // Skip duplicate records by checking a dictionary of seen keys
    If(HasKey($dict.seen_keys, $source_key),
      false,  // Already seen: skip
      AddToDict($dict.seen_keys, $source_key, true); true  // First occurrence: process
    );
    

For a detailed walkthrough of the deduplication pattern, see Detect and deduplicate records using hash functions.