Building a Converter FlowLast Updated: 08/11/2016 Introduced in Verision: 2.0 |
Converter flows are specially designated to create data or transform objects from one datatype to another. Because of their unique nature, converter flows are implemented as a mapping type, rather than as a sub-flow. Converter flows can be created just like any other flow, but their End Step must output an item or collection of items with a defined type. Such a converter flow may then be implemented in other flows by selecting Run Converter Flow as the Mapping type, and then selecting the converter flow you’d like to use.
Example
Our example will consist of two flows: a converter flow that will transform a list of user accounts into a list of the email addresses associated with those accounts, and a master flow that will display this list of email addresses within a form field.
- Use the Get All component to collect a list of user accounts.
- Use the Create or Copy component to create a list that will contain the email addresses.
- Add a data definition to the Create or Copy step.
- Use the ForEach component to iterate through a list of user accounts.
- Specify the ForEach step’s collection type, path and mapping type.
- Use the Add Item to List component to extract email addresses from the user accounts and add them to the list.
- Map the inputs and outputs for the Add Items to List step.
- Add an output to the End step so that the converter flow will output the list of email addresses.
The first step of our converter flow is to collect all of our user accounts. To do this, select the Get All component from the Flow Designer start-up window. This component can be found under the Integrations > All Integrations > Internal Services > Account Service category. Click Add to place it to our flow.
The next step of our converter flow will be to create a list which will eventually contain the email addresses we’ve extracted from our user accounts. To do this, drag the Create or Copy Data component from the Toolbox panel and place it in our flow. This component can be found under the Data category. Connect the steps as follows:
In order for the ForEach Step to know exactly which output contains the collected accounts we want it to iterate through, also specify the path and mapping type of its input. This control can be found in the Properties panel, under Inputs > Collection. Select Select Value and browse to the output of the step Get All 1 – GetAll1_Output.
Our flow is now set up to collect all of our system’s user accounts, create an empty list of email addresses, and iterate through the collected accounts, but we still have to extract the email addresses from the accounts collection and add them to our empty email addresses list. We can do this with the Add Item to List component, which can be found in the Toolbox panel, under Data > List.
Structure the paths from ForEach Step 1 so that each Next outcome or iteration will pass through the step Add Item to List 1. When the Add Item to List 1 step returns an outcome of Done, our flow will be directed back to ForEach Step 1. When ForEach Step 1 is Done, meaning that it has reached the end of our collected accounts, it will direct our flow to the End Step for final output.
To work correctly, Add Item to List 1 must know the type of list to which it will be adding items, and what those items will consist of. In Create or Copy Data 1 we defined our data as a list of strings, so we will select the type String in the ListType field.
Our original list was created in the step Create or Copy Data 1, and we can map that list by selecting and dragging the appropriate anchor from Email Address List to the input Original List.
Our last step in mapping the data for Add Item to List 1 will be to map the appropriate output. Because we want our email address list to be accumulative – that is, each time an email is added, the list is saved before adding the next – map our output back to the original list created in Create or Copy Data 1. To do this, drag the anchor for our output – New List – to Email Address List. With this last mapping completed, click OK to save our mappings.
Our converter flow is almost complete. The last step is to configure our flow to output the list of email addresses so they can be used in another flow. To do this, add output to our End step by clicking the Add button under Output in the Properties panel.
In this new pop-up, we’re allowed to choose any of the step outputs from our flow. Select Email Address List and click OK.