Text Formatter
Description
This unit is a Processor unit type.
The Text Formatter unit formats text included in the input events using the template provided. The template can reference input event fields at unit level, or global values at system level.
An event comes in through the in port. Then, the template format is applied. The input event is enriched with an extra field containing the formatted text and sent to the out port.
Undefined references to system variables will be considered as errors.
Undefined references to input event fields can follow various courses of action, configurable in the Undefined action field.
Configuration
After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:
Tab | Field | Description |
---|---|---|
General | Name | Enter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed. |
Description | Enter a description detailing the scope of the unit. | |
Formatted field name | The name of the output event field containing the formatted result. | |
Format | The template for the message to be generated. You can refer to input event fields at unit level, or global values at system level, using the following format:
| |
Undefined action | Select the action to perform when a field referenced in the template doesn't exist in the input event. Empty: leave empty. Null: insert "null". Mark: insert a mark in the form of {fieldName}. Fail: unable to perform any action. |
Input ports
Port | Description |
---|---|
in | Input events are expected to contain fields included in the template format. Fields that do not match the correct format will use the standard format for undefined values. |
Output ports
Port | Description |
---|---|
out | Outputs events enriched with an extra field (specified in the formatted field name setting) containing the formatted text. |
Example
In this example, we want to use variables to send string and integer fields as formatted text to a my.app data table.
First, we will use a Tick unit to send the fields when clicked.
In the Fields tab of the properties, add the following variables:
Then, we will link it to a Text Formatter unit in order to format the variable fields into text format.
In the Format field of the properties, enter the following expression:
%%{stringVariable} World has %%{integerVariable} words
In the Undefined action field, enter Fail for the action to perform when a field referenced in the template doesn't exist in the input event.
Finally, we will link its out output port to a Devo sink unit to send the formatted events to a my.app table.
Download this example
You can try this flow by downloading this JSON and uploading it to your domain using the Import option: