Return Dynamic Data Rows When Fetching Data From DatabaseLast Updated: 02/28/2016 Introduced in Verision: 2.0
Database entities represent external databases which can be integrated with a flow. To add a database within the portal, navigate to the folder System > Designers > Integrations > Databases, click the Add Databasebutton, and supply the necessary details. Once a database is introduced, components to query, insert, or update data to or from the database within the Flow Designer can be used. They are found under Integrations > My Integrations > Database > [Database Name] > [Table Name].
When Fetching Data from external database in the flow it is hard to work with because of its type. There are several options designed by Decisions to handle this.
In this example we are going to fetch data from database into Dynamic Rows and display it in the form. For this example we integrated with dbo_entity_account table from decisions database.
First, we begin in 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 Flow Designer Wizard on the workspace. In this Wizard we expand Integrations > My Integrations > Database > decisions2(Database) > 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 are going to use Wizard’s search bar to search for ForEach step. We select ForEach Step and click Add to add it to our flow.
Next, the Wizard asks us to pick the collection for the ForEach Step… We select entity_account_Result collection for our ForEach step and click Add to add it.
Next, we select our Get all from dbo_entity_account step from the workspace and configure its Output Data settings. We select Data Rows option from its Return Data Option dropdown list.
We connect our flow steps as follow and drag ForEach step’s Next outcome anywhere on the workspace to call Flow Designer’s Wizard. In the Wizard we select [Pick or Create Form] step from Flows, Rules, Forms and Reports > Forms[Interaction] category. We click Add to add this step to our flow and create new form to display our Dynamic Row.
The form is designed as follow… It displays two first fields from the Dynamic Row and it displays one row at the time. It has Next button as well to proceed to the next record.
When we finished with the form design we can save and close it to return back to our Flow Designer. If we check what data is available for our form in the flow designer we find out that ForEach step outputs for us a single Item that is of type DynamicDataRow and has numerous fields that we used in the flow to display our data.
Our Flow is completed and we can 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.
When the flow debugger runs we can see that first two field’s values from the first row of our database showed up as expected.
After clicking Next button and viewing all Dynamic Rows from the database our flow runs to the end step with no issues… And we can see it on the debugger’s diagram shown after the flow runs to its end step.