Create Form to Write to a Database Table

Last Updated: 05/03/2018 Introduced in Version: 2.0

This article will show you how to create a form that writes to a database table.

In this tutorial we will create a flow that lets us create new entries in a TV show database table. 

You’ll need to start with a designer project: http://documentation.decisions.com/creating-a-designer-project/

In order to read from a database or write to a database you’ll need a flow: http://documentation.decisions.com/creating-your-first-form/?display_cat=108

1. First step in this flow is to add a form. Select Show Form and click Add.

addform

2. Add controls to the form to gather data.  We will need the following fields:

  • Show Title
  • First Year
  • Number of Episodes
  • Network
  • Description

writetodatabaseform

3. Now that we have a form that can collect data we need to get this data to a database.  

You can integrate with an existing database table: http://documentation.decisions.com/integrating-an-external-database-with-a-flow/?display_cat=114, or you can create a new database stored type with in Decisions: http://documentation.decisions.com/simple-database-structure/?display_cat=131

For this example we will create a simple database type that looks like the screenshot below.  Please take note of the “Type Name” setting.  You will need this in the next step. 

simpledbstructure

4. Navigate back to the Flow Designer.  

5. Browse to the Quick Add menu.  

6. Under My Integrations > User Defined Types > Database Structures > TVShowTable, you will see steps related to your Simple Database Structure.  

quickadddatabase

7. Select the ‘Save’ step in your flow and click Add.

addsavestep

8. To get all the data from the form into the Save step you can double click the Save step and choose ‘Edit Input Mapping.’  The mapping editor is NOT the only way to setup the data in the save step, but it is a great way to visualize different data types and map data from one type into another.  We will use it to map the form data into the database table structure.  When you first open the mapping editor it will look like the screen shot below.

emptymappingeditor

9. On the right hand side you see a variable named ‘value’.  This is the new entry that will be written to the database.  Where the small orange text says ‘Unknown’ click, and change your option to ‘Build Data’.  Now you will see all the properties in your table.  

builddata

10. Drag lines from the fields on the left to the table structure on the right.

finishedmappingeditor

11. Run your process and check the database for your results.

Additional Resources