Array Operations

This action allows you to perform certain operations (such as split, concat, filter, pick, push, join, and reverse) on the given array. To achieve this, add this action to your canvas and configure it. Under ‘Select Array Operation’ field, you will find a list of array operations. Let us look at how to use each of these operations. 

 1. Split: This operation lets you split the given array into the specified number of parts. 

 Field data

 Source Array: Enter the source array you wish to split. 

 Split Into: Enter the number of parts into which you wish to split the array. For example, 4. 

 Round Robin Divide: Specify if you wish to split the array in ‘Round Robin’ fashion. By default, the value for this field is set to ‘False’. 

split.jpg

In the above example, if you set ‘Round Robin Divide’ to ‘False’, this action will return ‘[[“US”, “UK”], [“Canada, India”], [“Australia”]]’ as its output. However, if you set ‘Round Robin Divide’ to ‘True’, this action will return ‘[“US”, “India”], [“UK”, “Australia”], [“Canada”]’ as its output. 


2. Concat: This operation lets you concatenate two or more arrays into a single array. 

 Field data

 Source Array 1: Enter the first array. 

 Source Array 2: Enter the second array you wish to concatenate with the first array. You can add more arrays by clicking on ‘ADD’ link. 

concat.jpg

The example shown in the above image will return ‘["Robb", "Grey Wind", "Jon", "Ghost", "Sansa", "Lady", "Arya", "Nymeria", "Bran", "Summer"]’ as its output. 


3. Filter: This operation lets you define filters to retrieve only specific objects from the given array of objects. 

 Field data

 Source Array: Enter the array of objects on which you wish to apply filters. 

 Add Filters: This block contains basic filter options that can be applied on the given array of objects. To add these filters, click on ‘ADD’ link. 

       Input: Enter the name of the property on which you wish to apply filter. 

       Set Filter: Select the filter from the drop down list that you wish to set for the specified property. 

filter-1.jpg

In the example shown in the above image, we have set a filter which will return all the objects that contain an empty ‘age’ property. This will return [{"name": "Daenerys","City": "King's Landing","age": ""}] as its output. 

Add Advanced Filters: This block contains advanced filter options that can be applied on the given array of objects. To add these filters, click on ‘ADD’ link. 

        Input: Enter the name of the property on which you wish to apply filter. 

       Condition: Select the condition from the drop down that you wish to define for the specified property.

       Expected: Enter the value that you wish to check against the value of the property specified in the input field.

filter-2.jpg

In the example shown in the above image, we have set an advanced filter which will return all the objects in which the value of ‘age’ property is less than ‘30’. This will return [{ "name": "John","City": "Winterfell","age": 26 }, {"name": "Daenerys", "City": "King's Landing","age": 28 }] as its output. 


4. Pick: This operation lets you retrieve the values associated with the specified property from the given array of objects. 

 Field data

 Source Array: Enter the array of objects from which you wish to retrieve the values for a specific property. 

 Pick Property: Enter the name of the property to retrieve the values associated with it. You can values for multiple properties by clicking on ‘ADD’ link. 

pick.jpg

The example shown in the above image, will return ‘[{"City": "Winterfell"},{"City": "King's Landing"}] as its output. 


5. Push: This operation lets you append the specified items at the end of the given array. 

 Field data

 Source Array: Enter the source array to which you wish to add elements. 

 Add Items: This block lets you specify the elements you wish to add to the given array. To add array elements, click on ‘ADD’ link. 

           Items: Enter the element you wish to add to the array. You can add multiple elements by clicking on the ‘ADD’ link. 

push.jpg

The example shown in the above image will return ‘["Robb", "Grey Wind", "Jon", "Ghost", "Sansa", "Lady", "Arya", "Nymeria", "Bran", "Summer"]’ as its output. 


6. Join: This operator lets you convert all the array elements into a single string using the specified join operator. 

 Field data

 Source Array: Enter the array of which elements you wish to join as a single string. 

 Join By: Enter the join operator you wish to use. It can be a letter,word or any of the special characters. 

join.jpg

The example in the above image will return ‘["Robb&Grey Wind&Jon&Ghost&Sansa"] as its output.


7. Reverse: This operation lets you reverse the order of the array elements. 

 Field data

 Source Array: Enter the array that you wish to reverse. 

reverse.jpg

The example given in the above image will return ‘["Sansa", "Ghost", "Jon","Grey Wind","Robb"] as its output. 

Output:
  • output-arrow array-operations Array Operations
    • left-triangle output array