Building and Using Converter Flows
- Updated on 08 Mar 2019
- 3 minutes to read
Converter flows are regular flows that have had their flow behavior set to function in this way. For information on how to set flow behavior see Changing Flow Behavior .
Converter flows are designed to convert data of one data type into another data type (for example, a string into a datetime). In most cases, using a converter flow is not strictly necessary; there is almost always a way to use the data you need in its native type without converting it. However, using a converter flow can be helpful in cleaning up your data so it can be handled more elegantly in your process or displayed exactly how you want.
Converter flows are implemented in the mapping editor options of a given step. To set a step to use a converter flow, select Run Converter Flow in the Properties tab of a step under input or output. Then, select or create a converter flow to run.
Converter flows can run for both input and output data. I nput flows can have any number of inputs to them, but only one output of a given data type. Output converter flows can have any number of outputs, but only one input of a given data type.
Note that all the default conversion flows are found under System > Shared Designer Elements > System Defaults > Converter Flows . It is recommended to save any new converter flows to this location to keep them organized (however, it is not required).
This example will run a converter flow to change a string into a datetime. Create a date as a string and in a format that we don't want, then use a converter flow to convert the string into a datetime with the right format. (In the real world, it would of course be better to change the original input to be the type and format we want, but for the sake of this example we won't.)
Start in the Decisions studio and create a flow called Using a Converter Flow. (For more information on how to create a flow, see Creating Your First Flow .)
Add a Show Form step (in the Steps tab on the right under Favorite Steps ) and configure it with a Label and a Button. (For more information on creating a form with controls, see Creating Your First Form .) The Label control is configured as follows:
Save and close the form and the flow.
Now create the converter flow. Back in the designer folder create another flow as before. (For more information on how to create a flow, see Creating Your First Flow .) Call this flow Convert String to Date Converter Flow and configure it with a Create Data step (in the Steps tab on the right under Data ) and a Parse Date With Format step (in the Steps tab on the right under Data > Dates ).
In this example use the Create Data step to make data of the wrong type and format that we need to change. In the real world this represents any data passed into the flow that needs to be parsed and converted into a new data type.
For the Create Data step, in the Properties panel on the right under Data Definitions, create a string object called DateAsString and configure the input and output settings as follows:
For the Parse Date With Format step, configure the inputs and outputs as follows:
Save and close the flow.
Now set the flow behavior on the new converter flow. Back in the designer folder , right-click the Convert String to Date Converter Flow and click Edit > Advanced > Set Flow Behavior.
Select Converter Flow then OK.
Finally, set the form on the first flow to run the converter flow. Still in the designer folder, open the Using A Converter Flow again. Select the form and open its Properties panel on the right. Under Inputs , configure the Mapping Type and Converter properties as follows:
To test the flow, click Debug Flow in the top bar, then select the play arrow to launch the flow. If it works the form will display with the converted date:
Remember, this is the date originally defined as a string with an odd format:
As it is now displayed in the form, it is a datetime data type and in the correct format.