Database Structure CRUD Actions
  • 27 Jul 2022
  • 3 Minutes to read
  • Dark
    Light

Database Structure CRUD Actions

  • Dark
    Light

Article Summary

Overview

Database Structures are Data Structures typically used to create a table in the database to store information (e.g., customer information such as phone numbers or names). The following article will demonstrate how to use the Create, Read, Update, and Delete (CRUD) actions via Flow steps for Database Structures. 

CRUD Action Steps: Database Structures
In the Flow Designer's Toolbox, Create, Update, and Delete steps cannot be searched for. Users will have to navigate to USER DEFINED TYPES > DATABASE STRUCTURE to add CRUD actions to the workspace.

Example

In this tutorial, a Database Structure was created with the following attributes:

DatabasePerson
Firstname
String
Lastname
String
DOB
Date time
For more information on how to create a Database Structure Data Structure, please navigate to Creating A Simple Database Structure.

Create 

To create a record in the Person Data Structure:

  1. In a Designer Folder, select CREATE FLOW from the Global Action Bar.
  2. In the resulting Create Flow dialog, select and name the default Flow [Database Structure CRUD]
  3. Click CREATE to enter the Flow Designer. 
  4. In the Flow Designer, from the Toolbox tab on the left, navigate to USER DEFINED TYPES > DATABASE STRUCTURES > DATABASEPERSON.
  5. Drag and connect a Create DatabasePerson step to the Start and End step. 
  6. With the Create DatabasePerson step selected, navigate to the Properties panel > INPUTS > Item to Create field, and change its input mapping to Build Data.
  7. Notice the new list of INPUTS and navigate to FirstName, LastName, and DOB and change the input mappings from Ignore to Constant
    In this example, the input values are DOB: 3/17/2021, FirstName: Jill, LastName: Doe.

  8. Select Debug from the Top Action Bar. This will save and run the Flow, creating a record (row of relational data) on the DatabasePerson Data Structure.
    Auto ID Generation
    Despite being initially set to Ignore, note how the system auto-generates the record's ID upon creation by the Debug (Flow run) action.

    Update

    To update an existing record in a Database Structure Data Structure, the Edit Person or the Selective Update Person steps will be used. These steps are found in the Toolbox tab on the left under USER DEFINED TYPES > DATABASE STRUCTURES > DATABASEPERSON. The Edit Person step will change every data field in the object, even if only one data field has been changed. To change only one or more data field value and maintain the rest of the data field values, the Selective Update step is recommended. In order to change any record in a Data Structure, the Fetch Entities step will be required to fetch or read a particular record. Then it will pass the Id of the record to be changed into the Edit Person or Selective Update steps.

    Edit Person Step

    When using the Edit Person step, notice it is configured similar to the Create Person step in the Properties panel > INPUTS > Item to Edit where the input mapping is set to Build Data. However, the ID has a Select From Flow mapping and EntityResults is selected and drilled down to First, then ID. Also, for this example, the Edit Person step has been configured with a new random FirstName, LastName, and DOB.
    If the Edit step is used to change one field, that field will update with the new value, and all unchanged fields will be set to Null or Empty.

    Selective Update Person Step

    When using the Selective Update Person step, configure Properties panel > INPUTS > ID to a Select From Flow input mapping and select Entity Results, drill down and click First, then ID. In the Properties panel > DATA > DOB and FirstName are configured with random information and still have a Constant input mapping.

    Delete

    To remove records from a Data Structure, the recommended step is the Delete Person step found in the Toolbox tab on the left under USER DEFINED TYPES > DATABASE STRUCTURES > DATABASEPERSON.  This step will expect an Id as an input. Once an Id has been provided, running the Flow will delete that record from the Data Structure.

    The Id can be found by selecting EntityResults and drilling down to First. 


Was this article helpful?