Array Operations
Use this action to perform array operations such as split, concat, filter, pick, push, join, and reverse on the array.
Using Array Operations Action
To use this action in your workflow, connect it to ThingWorx Flow. To connect to the flow, do the following:
1. Click and drag the Array Operations action under the Operations utility to the canvas, place the pointer on the action, and then or double-click the action. The Array Operations action window opens.
2. Edit the label name, if needed. By default, the label name is same as the action name.
3. To add an operation, select an array operation from the list.
Split—Split the given array into the specified number of parts.
Concat—Concatenate two or more arrays into a single array.
Filter—Define filters to retrieve only specific objects from the given array of objects.
Pick—Retrieve the values associated with the specified property from the given array of objects.
Push—Append the specified items at the end of the given array.
Join—Convert all the array elements into a single string using the specified join operator.
Reverse—Reverse the order of the array elements.
This video demonstrates how to work with arrays when defined in any workflow.
Using the Split Array Operation
To use the Split Array Operation, enter the following details:
1. Source Array—Source array that you want to split.
2. Split Into—Splits the source array into given number of parts. If an array has only 2 items and the divide number is 3, then 3rd array will be empty. The max divide number is 100.
3. Click + to view the additional fields:
Round Robin Divide—Split the array in Round Robin fashion.
For example, if the source array is set to ["US","UK","Canada","India","Australia"] and the Split Into value is set to 3, and the Round Robin Divide option is set to False, this action returns the following output:
[["US", "UK"], ["Canada", "India"], ["Australia"]]
However, if you set Round Robin Divide option to True, this action returns the following output:
["US", "India"], ["UK", "Australia"], ["Canada"]
4. Click Done.
Using the Concat Array Operation
To use the Concat Array Operation, enter the following details:
1. In the Add Source Array section, enter the details that follows:
Source Array—The first array
Source Array—The second array to concatenate with the first array.
Click Add to enter multiple source array.
2. Click Done.
Using the Filter Array Operation
The Filter option works with first level array elements only.
To use the Filter Array Operation, enter the details that follows:
1. Source Array—The array of objects on which to apply filters.
2. Click + to view the additional fields.
In the Add Filters section, click Add to enter the filter details.
Input—The name of the property on which to apply filter.
Set Filter—Select one of the option from the list.
To add multiple filters, click Add.
To use advanced filters, in the Add Advance Filters section, click Add to enter the advance filter details.
Input—Name of the property on which to apply a filter.
Condition—Condition to define for the specified property.
Expected—Value to check against the value of the property specified in the input field.
To add multiple advance filters, click Add.
3. Click Done.
Using the Pick Array Operation
To use the Pick Array Operation, enter the details that follows:
1. In the Source Array field, enter the array of objects from which to retrieve the values for a specific property.
2. Click + to view the additional fields.
In the Add Pick Properties section, click Add to enter pick properties.
In the Pick Property field, enter the name of the property to retrieve the values associated with it.
To enter multiple pick properties, click Add.
3. Click Done.
Using the Push Array Operation
To use the Push Array Operation, enter the details that follows:
1. In the Source Array field, enter the source array to which you want to add elements.
2. In the Add Items section, click Add to enter the items.
Type—Type of an item to push in an array.
Value—Value of an item to push in an array.
Click Add to add multiple items.
3. Click Done.
Using the Join Array Operation
To use the Join Array Operation, enter the details that follows:
1. In the Source Array field, enter the array of which elements to join as a single string.
2. In the Join By field, enter the join operator to use.
3. Click Done.
Using the Reverse Array Operation
To use the Reverse Array Operation, in the Source Array field, enter the array to reverse, and then click Done.
Output Schema
The Array Operations action returns an output schema as shown in the figure that follows:
Was this helpful?