Operations

Transform

The Transform operation allows you to apply custom JavaScript code to transform your data during the processing pipeline. This operation is applied during the transformation phase and enables you to perform complex data manipulations that aren't possible with standard operations.

Overview

The Transform operation enables you to:

  • Write custom JavaScript code to manipulate your data
  • Apply transformations to all entities in your dataset
  • Implement complex business logic for data processing
  • Use the full power of JavaScript to modify field values, create new fields, or restructure data

Configuration

JavaScript Code Editor

The Transform operation provides a code editor where you can write custom JavaScript functions:

  1. The code should be a valid JavaScript function
  2. The function receives data records and should return transformed records
  3. You can use any JavaScript features supported by the platform
  4. The transformation is applied to all entities in the pipeline

Examples

Basic Data Transformation

To apply a simple transformation to all data:

  1. Add the Transform operation to your rule
  2. Write JavaScript code like:
// Example: Convert all email addresses to lowercase
record.email = record.email.toLowerCase();
return record;

Complex Transformations

For more complex data manipulations:

  1. Add the Transform operation to your rule
  2. Write JavaScript code that processes records:
// Example: Create a new full_name field from first_name and last_name
if (record.first_name && record.last_name) {
  record.full_name = record.first_name + ' ' + record.last_name;
}
// Example: Calculate age from birth_date
if (record.birth_date) {
  const birthDate = new Date(record.birth_date);
  const today = new Date();
  record.age = today.getFullYear() - birthDate.getFullYear();
  const monthDiff = today.getMonth() - birthDate.getMonth();
  if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
    record.age--;
  }
}
return record;

This operation provides maximum flexibility for data processing, allowing you to implement custom logic that meets your specific requirements.

On this page