Using Converters When Fetching Data From Database

Last Updated: 07/27/2018 Introduced in Version: 2.0

Overview

This example demonstrates how to create a database table within Decisions and use a converter in a flow to retrieve from the database table. Database entities represent external databases which can be integrated with a flow. 

 

Example

Fetching Data from an external database in the flow can be hard to work with due to its type. There are several options designed by Decisions to handle this.

The first option is described in this article. We are going to register Converter Flow to convert the database specific type to Decisions’ native Account type Object.

For this example we integrated with dbo_entity_account table from decisions database. For more information on integrating tables click here: 

First, we begin in a Designer Folder by clicking Create Flow to create a new flow.

 

Next, name the flow and click Create to proceed to the Flow Designer.

 

 

Flow Designer opens with Quick Add Step dialog on the workspace. In this dialog we expand Integrations > My Integrations > Database > LocalConnection > dbo.entity_account> (Table) category and select Get all from dbo.entity_account step. Click Add to add this element to our workspace.

 

 

Next, we type “foreach” in dialog’s search bar to search ForEach step. We select it and click Add to add it to our Flow.

 

Next, Quick Add Step dialog provides us with a new pop-up window where we can pick a collection for our ForEach step to process. We select entity_account_Result which is a collection gathered by our Get all step from the database table. We click Add to add this collection to ForEach step.

 

Next, we need to create a new form to display Accounts. In the dialog we expand Flows, Rules, Forms and Reports > Forms [Interaction] category and select [Pick or Create Form] step.

 

This form was designed as follows to display one record at the time. The input data that is acceptable for this form is of Account type.

 

 

When we save and close Form Designer we can connect the steps in our flow and save it. Mention that ForEach step outputs Item that is of database specific type and our Form accepts Account type. We need to create converter flow to handle this. Close this flow.

 

Part 2.

Back in the Designer Folder click Create Flow to create a new flow.

 

Next name the flow. From Behavior dropdown list pick Converter Flow because we are creating converter flow. Click Create to proceed to the Flow Designer.

 

In the Flow Designer select start step. In the right panel locate Flow Input Data box and click Add New link.

 

We name the input data and define its type. For the type we search a specific type that outputs our database. Click Ok to save and close Input Data definition window.

 

Next, select end step on our workspace. In the right panel locate Output Data box and click Add New link.

 

We name the Outcome data and select Account type for it. When finished we click Ok to save and close this pop-up window.

 

Next, we connect start and end step, and select Show Mapping Editor for our end step.

 

 

In the mapping editor we expand accountIn and accountOut and map the fields as needed. When finished we click Ok to save and close Mapping Editor. This completes our Converter Flow so we can save and close it.

 

Back in the Designer Folder we locate our first flow and click Edit from its thumbnail.

editFlow

We can see that our form has validation issues because the Item produced by ForEach step needs to be converted into Account type. We select Show Mapping Editor for our Form step.

 

When we map Item to Account we can see the error that tells us that two type are Incompatible.

 

mapItemToAcc

If we click on this item’s mapping type we will see our converter flow as one of the mapping type options. We choose this option…

useConverterFlow

It automatically finishes our mapping. We click Ok to save and close Mapping Editor.

mappingForFormFinished

This completes our flow so we click Debug Flow link at the top panel of our Flow Designer to test our flow.

Note that in Decisions version 3.5 and above, you’ll need to click the Test Flow link to access the Debugger.

3.5 Test Flow Shot

debugFlow

Our flow starts executing in the debugger and first Account shows up in our form.

firstAccountAppears

After all Accounts showed up our flow successfully runs to the end step with no issues.  

debugDiagram

Additional Resources