Please note this is a semi-technical feature.
Many iPaaS platforms today don’t offer a way to fetch a collection of multiple items, and those that do require you to use code. This is problematic because non-technical people also need access to this task sometimes. For instance, some providers may offer an action that helps you fetch a collection of all the notebooks available in your Evernote account. However, your ‘collection’ of information includes a lot of details about the notebooks like the title, description, id, date of creation, and version. But in most cases, you simply want the titles of the notebooks. And to do this, you have to write some code.
This is a major pain point that the new ‘Formatter’ action addresses. It lets you pick any element or value of any key from a collection and use it in another action without writing any code. So, in the above example, you can easily fetch only the names of all the notebooks and pass them to other action in your workflow.
The Formatter action allows users to format, transform, or extract text and html data quickly and easily. It provides various ways to separate data such as adding in a new line, comma, semicolon, colon, bar, tab, and more for text formatting. For HTML, Formatter provides ordered lists, unordered lists, and table format data.
In this post, we’ll walk you through how to use Formatter.
How Formatter Works
Because this is a semi-technical feature, we’ll walk you through how to achieve customized and formatted data from a collection of data items.
Build a workflow with a collection
Before getting started with Formatter, you need a workflow that uses an action that returns a collection (defined as an array of objects). Once implemented, you can format that data using the 'Formatter' action.
The action we’ll use as an example is Evernote’s ‘Get List of Notebooks’. It returns a collection that contains a lot of data about all the notebooks in your account. In the steps given below, you’ll learn how to fetch only the titles of the notebooks using Formatter. You’ll also learn what outputs are available for your data.
Add the ‘Evernote - Get List of Notebooks’ action to your workflow. Configure this action as you normally do. Then, add the Formatter action.
Here’s how to use Formatter.
Choose your collection
1. Select a 'collection' to be formatted
In this example, that’s ‘Evernote — Get List of Notebooks’. In the ‘Select a collection’ field, select the collection from which you wish to fetch details. In this case, there is only one collection available – Notebooks.
Select Your Format Type
2. Select format type — Text
To format your collection in text format, go to the 'Select format type' field of your configuration page and choose the 'text' option
Next to to ‘Select Fields’ and choose the value that you want to extract.
If you want to extract all the titles of the notebooks from your Evernote account, you need to select the 'Notebooks Name' key from the dropdown options.
Now, the next field ‘Select record separator’ lets you apply a record separator on your collection data. This option specifies how you wish to format or structure your output. Lets select 'New Line' from the list of record separators. This will structure the data in such a way that each title is printed on a new line.
You can use 'Gmail — Send an Email' action to check your formatted output. Save and Test your flow.
2.1. Formatted output using record separator:
For 'New Line' separator
For 'Comma' separator
3. Select format type — HTML
If you wish to print the data in HTML format, you need to select 'html' option in the 'Select format type' field of your configuration page, and then select a relevant list type.
For HTML formating, the customized output can be retrieved in the form of unordered list, or ordered list, or table format. This option specifies how you wish to format or structure your output.
Selecting the 'unordered list' option from the 'Select list type' field formats your collection into an unordered list (bullet points). You can use Gmail — Send an Email action to view your formatted output. Note that you need to select 'HTML' in the 'body type' field of Gmail action. This is applicable only if you wish to retrieve your customized output in HTML format type.
3.1 Output for Ordered list
3.2 Output for Unordered list
Similarly, if you select 'table' option from the 'Select list type' field of Formatter action, you will retrieve output in a tabular format.