Array operations
You can manage arrays by using the following transform operations.
Chunk
You can split an array into a specific number of chunks.
The input fields are as follows:
- Array
- Source array that contains the elements that you want to split into chunks.
- Size
- Number of chunks you want to split the array into.
Example - If an array has 10 elements and you divide it into 4 chunks, the elements are distributed sequentially. The first three chunks contain 3 elements each, and the last chunk contains 1 element.
Filter
You can filter out only specific elements of an array based on the specified conditions.
- Array
- The source array from which specific elements are filtered.
- Add filters
- Define basic conditions to check against each array element. If all conditions match, the
associated element is included in the transform output. To add a basic condition, click
+ under the Add Filters label.
- Key
- Specify the array key on which the condition is applied.
- Set Filter
- Select the relevant condition that you want to set on the specified key.
- Add advance filters
- Define advanced conditions to check against each array element. If all conditions match, the
associated element is included in the transform output. To add an advanced condition, click the
+ icon under the Add Filters label.
- Key
- Specify the array key for the condition.
- Set Filter
- Select the relevant condition that you want to set on the specified key.
- Expected
- Enter the expected value that must match the value of the specified key.
Example - If you set the key to project, the filter to matches, and the expected value to Sales, only array elements with project as Sales are included in the output.
Index Of
You can retrieve the index of the first occurrence of a specified value in an array by traversing it in sequence. If the item is not found, it returns -1 as the output.
The input fields are as follows:
- Array
- Source array that contains the element whose index you want to fetch.
- Item
- Value of which index you want to fetch.
- Key
- If you have a specified array of objects in the Array field, enter the key for the specified value here.
Example - If you specify 12345 as the item, the array is searched starting from the 0th index for the first occurrence of 12345. When it is found, the index of that item is returned.
Is Array
You can get check whether the specified input is an array or not. If its array it returns true, otherwise it returns false.
The input field is as follows:
- Array
- Source array you want to check.
Example - If you enter a valid array in the array field, it returns true in the response.
Join
You can join some or all elements of an array with the specified separator.
The input fields are as follows:
- Array
- Source array that contains the elements that you want to join.
- Join By
- Separator that you want to use to join the array elements. For example, ~, #, *.
- Join Last Item By
- Separator that you want to use to join the second last and last element of the array. For example, ~, #, *.
- Key
- If an array of objects in the Array field is passed, provide the specific key of which values you want to join by using the specified separator.
Example - If the array is [{“id”: “123”, “name”: “John”}, {“id”: “456”, “name”: “Sansa”},
{“id”: “789”, “name”: “Arya”}], and you specify ~ as the separator in the Join
By field, you get, {“id”: “123”, “name”: “John”}~{“id”: “456”, “name”:
“Sansa”}~{“id”: “789”, “name”: “Arya”} in the output. If you enter % as a separator in the
Join Last Item By field, you get {“id”: “123”, “name”: “John”}~{“id”:
“456”, “name”: “Sansa”}%{“id”: “789”, “name”: “Arya”} in the output. If you enter ID in the
Key field, you get 123~456%789 in the output.
Last Index Of
You can retrieve the index of the first occurrence of the specified value in an array by traversing it in reverse order. If the specified item does not exist in the array, it returns -1 as the output.
The input field are as follows:
- Array
- Source array that contains the element of which index you want to fetch.
- Item
- Value of which index you want to fetch.
- Key
- If you have a specified array of objects in the Array field, enter the key for the specified value here.
Example - If you specify 12345 as the item, the array is searched from the last element for the first occurrence of the value 12345. If it appears at the 1st and 6th positions, the Last Index Of operation returns 6.
Merge
You can merge two or more arrays.
The input fields are as follows:
- Arrays
- Click + to provide the arrays you want to merge.
- Array
- Array you want to merge with the rest of the arrays.
Example - If you have two arrays, [1,2,3,4] and [5,6,7,8], the
Merge operation output is [1,2,3,4,5,6,7,8].
Pick
You can pick certain properties from the array.
The input fields are follows:
- Array
- Array from which you want to pick specific properties.
- Property
- The key of which value you want to pick from the array. You can specify multiple keys by clicking + under the Property label.
Example - If [{"id": "123", "name": "John", "City": "Winterfell"}, {"id": "456", "name":
"Sansa", "City": "Westeros"}] is the array, and you specify "ID" and "name" in the
Property fields, you get [{"id": "123", "name": "John"}, {"id":
"456", "name": "Sansa"}] as the output of the Pick operation.
Pop
You can remove the last element from an array.
- output
- The array after removing the last element.
- removed Element
- Returns the last element that is removed from the array.
The input field is as follows:
- Array
- Array from which you want to remove the last element.
Example - If [1,2,3,4,5] is the array, the output key returns
[1,2,3,4] and the remove Element key returns 5.
Push
You can push one or more elements to an existing array.
The input fields are as follows:
- Array
- Array to which you want to push to the element. This element is pushed at the end of the existing array.
- Item
- The item you want to add to the array.
- Item Type
- The type of the specified item. Make sure that the item type matches the item that is specified, otherwise the workflow produces an error.
Example - If [1,2,3,4,5] is the array and you add demo string as an
Item, the Push operation returns
[1,2,3,4,5,"demo"] as the output.
Remove
You can remove the specified element from an array.
The input fields are as follows:
- Array
- Array from which you want to remove the element.
- Remove by
- Specify the method that you want to use to remove the element. The following options are available:
- Index
- Specify the index of the element that you want to remove.
- Item
- Specify the item that you want to remove from the array.
Example - If [1,2,3,4,5] is the array and you specify 2 as the
Index, the Remove operation returns [3].
Reverse
You can reverse the elements of the array.
The input field is as follows:
- Array
- Array that contains the elements that you want to reverse.
Example - If [1,2,3,4,5] is the array, the Reverse operation
returns [5,4,3,2,1].
Size
You can retrieve the number of elements in an array.
The input field is as follows:
- Array
- The array whose element count you want to retrieve.
Example - If [1,2,3,4,5] is the array, the operation output returns 5.
Splice
You can remove one or a specified number of sequential elements from an array.
The input fields are as follows:
- Array
- Array from which you want to remove one or more elements.
- Start Index
- Index of the element you want to remove. If you want to remove more than one element from the array, specify the index from which you want to start removing elements.
- End Index
- Specifies the index up to which elements are removed during the splice operation.
Example - If [1,2,3,4,5] is the array, and you specify 3 as the Start
Index, the Splice operation returns [1,2,3,5], and the
spliced elements are [4].
If [1,2,3,4,5] is the array, and you specify 1 as the Start
Index and 3 as the End Index, the Splice operation
returns [1,4,5], and the spliced elements are [2,3].