Welcome to Zuora Product Documentation

Explore our rich library of product information

Advanced Transformer

Use the Advanced Transformer when the incoming usage event shape does not match the event shape required for billing or downstream processing.

The Advanced Transformer lets you transform a single input event into one output event, multiple output events, or no output events at all.

Common use cases include renaming or deriving fields, splitting one incoming record into multiple billable records, filtering out records that should not be rated, and reshaping events so they match a required output schema. Each event returned by the Advanced Transformer is validated against the output schema that you select so downstream operators receive predictable, well-structured data.

How the Advanced Transformer works

The Advanced Transformer is a pipeline operator that runs custom code on each incoming event.

At a high level:

  1. An event enters the Advanced Transformer.

  2. Your script runs once for that event.

  3. The script returns an array of output events.

  4. Each returned event is validated against the selected output schema.

  5. Valid events continue to the next operator in the pipeline.

Your script can return:

  • one event for a standard reshape

  • multiple events when one input should expand into many billable records

  • an empty array when the event should be dropped

Write transformation logic

The editor provides a starter function. Write your logic inside that function and always return an array.

Example JavaScript:

function transform(event) {
  const items = event.items || [];

  return items.map(function (item) {
    return {
      accountId: event.accountId,
      sku: item.sku,
      quantity: item.quantity,
      eventTime: event.eventTime
    };
  });
}

Example input:

{
  "accountId": "A-100",
  "eventTime": "2026-06-01T00:00:00Z",
  "items": [
    { "sku": "API_CALLS", "quantity": 50 },
    { "sku": "STORAGE_GB", "quantity": 12 }
  ]
}

Example output:

[
  {
    "accountId": "A-100",
    "sku": "API_CALLS",
    "quantity": 50,
    "eventTime": "2026-06-01T00:00:00Z"
  },
  {
    "accountId": "A-100",
    "sku": "STORAGE_GB",
    "quantity": 12,
    "eventTime": "2026-06-01T00:00:00Z"
  }
]

In this example, one bundled usage event is expanded into multiple item-level usage events.

Drop events that should not be rated

Return an empty array to remove an event from the pipeline.

function transform(event) {
  if (event.quantity <= 0) {
    return [];
  }
  return [event];
}

Expected outcome

After you save and run the meter:

  • each input event is processed once

  • the pipeline emits the events returned by your code

  • every output event conforms to the selected schema

  • downstream operators receive the transformed events

  • you can verify the results in the audit trail

Common scenarios

  • The operator will not save: Make sure all required fields are set: language, code, and output schema.
  • Output events fail validation: Check that the fields and types in your returned object match the selected schema exactly.
  • Python is not available: Python is available only when it is enabled for your tenant.
  • Returning multiple events: You can return multiple events when one input should expand into many outputs.
  • Filtering out events: You can return an empty array for events that should not be kept.
  • Testing with sample data: Run the meter with a small sample input and inspect the operator output in the audit trail.
  • Output schema selection: Create or locate the required schema in the Schema Registry and select it in the operator.