Purpose
The merge task allows you to combine data from job variables, static data, and tasks' outgoing variables to create a new variable. By merging data, you can create new data structures to match an existing task's parameters, which allows you to reuse existing tasks without programming new tasks. A merge task can combine number, boolean, string, array, and object data types.
When merging data, one of two modes are supported.
Mode | Description |
---|---|
No keys assigned to merged data | The merge task returns an array of the merged values in a non-deterministic order. See the examples below. |
Unique keys assigned to merged data | The merge task returns an object with key/value fields as specified. See the examples for this task. |
Note: The merge task does not support merging data with partial key assignments or non-unique keys.
Properties
Property | Description |
---|---|
Key (optional) | Specify a key for each merged value. Supported configurations are either no keys or all unique keys. |
Task (required) | Specify where to find a variable to merge. You can merge data stored in job variables, a static value, or an earlier task's outgoing variable. |
Variable | Specify the data to merge in the Variable field. When the data comes from the job or an earlier task, select the variable from the dropdown list. If the data comes from a static value, type the value in the variable edit box. |
Add/Remove/Reorder | Add, remove, and reorder the merged data. |
Control Buttons
Control | Icon | Function |
---|---|---|
Add row | + | Add a row below the relevant row. |
Delete row | - | Remove a row. |
Move row up | ![]() |
Move row up one row. |
Move row down | ![]() |
Move row down one row. |
Example
Create a three-element array by merging data returned from three different tasks.
Assume three tasks return these objects:
{ "vendor": "Cisco", "platforms": [ "3945", "6500" ], "chassis": [ "fixed", "modular" ] } { "release": "15.5" } { "features": [ "L3VPN", "STP" ] }
Configure the merge task properties with no keys as shown below.
Figure: Insert Merge
The merge task returns an array and the order is not deterministic.
[ { "vendor": "Cisco", "platforms": [ "3945", "6500" ], "chassis": [ "fixed", "modular" ] }, { "release": "15.5" }, { "features": [ "L3VPN", "STP" ] } ]
Create an object by assigning unique keys to each merged value.
- In addition to the three objects used in the previous example, the merge includes a number, string, boolean, and array.
Configure the merge task's properties with unique keys as shown below.
Figure: Edit Merge
The merge task returns an object.
{ "chassis": { "vendor": "Cisco", "platforms": [ "3945", "6500" ], "chassis": [ "fixed", "modular" ] }, "os-image": { "release": "15.5" }, "services": { "features": [ "L3VPN", "STP" ] }, "myNumber": 13, "myString": "hello world", "myBoolean": true, "myArray": [ "apple", "pear" ] }