RAP Logo

change

Modify message properties, set variables, and transform data structures.

change Block

The change block is used to set, change, delete or move properties of a message, flow context or global context. The node can specify multiple rules that will be applied in the order they are defined.

Overview

The change block provides four main operations:

  • Set: Set a property. The value can be a variety of different types, or can be taken from an existing message or context property.
  • Change: Search & replace parts of the property. If regular expressions are enabled, the "replace with" property can include capture groups, for example $1. Replace will only change the type if there is a complete match.
  • Delete: Delete a property.
  • Move: Move or rename a property.

The "expression" type uses the JSONata query and expression language.

Configuration Options

Operations

The block supports multiple operations that can be configured:

Set Operations

  • Set msg.property: Set a property in the message object
  • Set flow.property: Set a property in the flow context
  • Set global.property: Set a property in the global context

Change Operations

  • Change msg.property: Modify an existing message property
  • Change flow.property: Modify an existing flow context property
  • Change global.property: Modify an existing global context property

Move Operations

  • Move msg.property: Move a property from one location to another
  • Move flow.property: Move a flow context property
  • Move global.property: Move a global context property

Delete Operations

  • Delete msg.property: Remove a property from the message
  • Delete flow.property: Remove a property from flow context
  • Delete global.property: Remove a property from global context

Value Types

For each operation, you can specify the value type:

  • String: Plain text value
  • Number: Numeric value
  • Boolean: True/false value
  • JSON: JSON object or array
  • Date: Date/time value
  • JSONata Expression: Dynamic expression evaluation
  • Environment Variable: System environment variable
  • Flow/Global Context: Reference to context values

Common Use Cases

Data Transformation

Transform incoming data to match expected format:

{
  "operations": [
    {
      "action": "set",
      "target": "msg.payload.processedAt",
      "value": "{{$now()}}",
      "valueType": "jsonata"
    },
    {
      "action": "set",
      "target": "msg.payload.status",
      "value": "processed",
      "valueType": "str"
    }
  ]
}

Property Mapping

Map properties from one structure to another:

{
  "operations": [
    {
      "action": "move",
      "target": "msg.payload.userId",
      "source": "msg.payload.id"
    },
    {
      "action": "move",
      "target": "msg.payload.userName",
      "source": "msg.payload.name"
    }
  ]
}

Context Management

Store and retrieve values from context:

{
  "operations": [
    {
      "action": "set",
      "target": "flow.processedCount",
      "value": "{{flow.processedCount + 1}}",
      "valueType": "jsonata"
    },
    {
      "action": "set",
      "target": "global.lastProcessed",
      "value": "{{$now()}}",
      "valueType": "jsonata"
    }
  ]
}

Data Cleaning

Remove unnecessary properties:

{
  "operations": [
    {
      "action": "delete",
      "target": "msg.payload.tempData"
    },
    {
      "action": "delete",
      "target": "msg.payload.debugInfo"
    }
  ]
}

Advanced Features

JSONata Expressions

Use JSONata expressions for dynamic value calculation:

{
  "operations": [
    {
      "action": "set",
      "target": "msg.payload.fullName",
      "value": "{{payload.firstName & ' ' & payload.lastName}}",
      "valueType": "jsonata"
    }
  ]
}

Conditional Operations

Apply operations based on conditions:

{
  "operations": [
    {
      "action": "set",
      "target": "msg.payload.priority",
      "value": "{{payload.amount > 1000 ? 'high' : 'normal'}}",
      "valueType": "jsonata"
    }
  ]
}

Tips

  • Use the change block early in your flow to standardize data formats
  • Combine multiple operations in a single change block for efficiency
  • Use JSONata expressions for complex data transformations
  • Store frequently used values in flow or global context
  • Use meaningful property names to improve flow readability
  • Test your JSONata expressions using the expression editor

Notes

  • The change block processes operations in the order they are configured
  • Context values persist across message flows within the same flow or globally
  • JSONata expressions have access to the current message and context
  • The block can handle multiple operations in a single execution
  • Property paths use dot notation (e.g., msg.payload.user.name)