How to retrieve specific objects from an array
Many actions in Built.io Flow return an array as output. There may, however, be cases when you need only a select few objects from an array, and not the entire array. This can be done with the help of ‘Array Operations’ action.
In this tutorial, we will look at an example that will help you learn how to retrieve specific objects from an array.
The ‘Wunderlist - Get List’ action returns all the list (array) available in your Wunderlist account. Let’s say you wish to retrieve only those lists that contain the word ‘test’ in the title, and not all the lists.
To do this, follow the instructions given below.
Step 1. Add actions
Add 'Wunderlist_Get Lists', 'Array Operations', and 'Gmail_Send an Email' action to your canvas and connect them as shown below:
Step 2. Configure ‘Get Lists’ action
Configure 'Wunderlist_Get Lists' action as given below:
Authorize Wunderlist: Select the Wunderlist authorization from the drop-down list. If you have not created an authorization yet, click on 'Add new' to create one.
Once you have selected an access token, click on 'Done'. This will take you back to canvas.
Step 3. Configure ‘Array Operations’ action
Configure the 'Array Operations' action as given below:
Field data
Select Array Operation: Select 'Filter' option from the drop-down list. This lets you apply filters on the given array.
Source Array : Add the output of 'Get List' action given on the right hand side of the configuration window, as an input for this field.
Next, click on the '+Show Additional fields' link and click on '+ADD' link given under 'Add Filters' section to apply a filter on the input array.
Add Filters_Filter 1:
- Input: Enter 'title' as an input for this field.
- Set Filter: Select 'isString' option from the drop-down list. This filter is used to check if the title of the list is string.
Next, click on the '+ADD' link given under 'Add Advance Filters' section to apply conditional filter on the input array.
Add Advance Filter_Filter 1:
- Input: Enter 'title' as an input for this field.
- Condition: Select 'Matches' option from the drop-down list. This filter is used to set a condition that checks if the title of the list contains the word 'test'.
- Expected: Enter '/test/i' as an input for this field. By default, the search filters are case sensitive. In order to perform a case insensitive search, we will use this regex expression where 'test' is the keyword that you wish to search and 'i' is the modifier for case insensitive match.
Once you have entered all the details, click on 'Done'. This will take you back to canvas.
Step 4. Configure ‘Send an Email’ action
Configure the 'Gmail_Send an Email' action as given below:
Authorize Gmail: Select the Gmail access token from the drop-down list. If you have not created an access token yet, click on 'Add new' to create one.
To: Enter the email ID of the recipient to whom you wish to send the details of the list.
Body: Add the output of 'Array Operations' action given on the right hand side of the configuration window, as an input for this field.
Once you have entered the details, click on 'Next', test the action, and click on 'Done' to return to the canvas. Then click on the 'Run' icon located at the top right-hand side corner of the canvas to run the workflow. This will retrieve the details of all lists that contain the word 'Test' in their title and will send it to the specified recipients via Gmail.