Write New

The Write New stage writes events to an Output that doesn’t exist under the Connection. This is a more flexible away to control the Output settings and is recommended if Outputs definitions are not being shared between Pipelines.

Stage Write New Target

Connection

Use the reference panel to define the Connection to use for the write. This controls the available output options.

Write Properties

Once a Connection is selected define connection-specific settings. See Connections for connector-specific details.

The properties of the new Target can be defined in three ways:

  1. Static/constant settings
  2. Dynamically using {{}} expressions. When defining properties this way, content within the {{}} is evaluated as a Javascript concise statement w/ implicit return. The javascript expression can use event and System object.
  3. Dynamically using the Write Properties Expression field. This is only required for advanced use cases that require additional Javascript to generate the property settings.

Using an inline reference

The results of constant settings, {{}} expressions, and the Write Properties Expression combine to define the write properties used by the stage. For example, using an MQTT Connection, the Topic setting can be generated using value’s name attribute and current date by using {{event.value.name}}/{{new Date().toISOString()}} for the attribute setting.

Using a Write Properties Expression

Advanced use cases may require additional Javascript in order to generate the properties required to define the new Target. In the Write Properties Expression, use the event and stage objects to set properties based on event.value. This feature is most useful when setting properties that are not simple values, like arrays for example.

typescript
class Stage {
    /**
     * Sets the write properties object. The object properties are merged with values defined in the configuration (static or inline references)
     **/
    function setWriteProperties(value: object);

    /**
     * Sets a single write property by name. The object property is merged with values defined in the configuration (static or inline references)
     */
    function setWriteProperty(name: string, value: any);
}

Examples below show how to set write values for single properties or multiple properties at once.

javascript
    // Set a single topic for MQTT
    stage.setWriteProperty("topic", "my/topic");

    // Set multuple values
    stage.setWriteProperties({topic: "my/topic", qos: 0});
} 

Success / Failure

See the Write Stage. Success and Failure paths work the same for Write New, with the main difference being Write New writes to a single target vs. one or more targets.