- 27 Jul 2022
- 3 Minutes to read
- Print
- DarkLight
Database Structure CRUD Actions
- Updated on 27 Jul 2022
- 3 Minutes to read
- Print
- DarkLight
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.
Example
In this tutorial, a Database Structure was created with the following attributes:
DatabasePerson | |
Firstname | String |
Lastname | String |
DOB | Date time |
Create
To create a record in the Person Data Structure:
- In a Designer Folder, select CREATE FLOW from the Global Action Bar.
- In the resulting Create Flow dialog, select and name the default Flow [Database Structure CRUD].
- Click CREATE to enter the Flow Designer.
- In the Flow Designer, from the Toolbox tab on the left, navigate to USER DEFINED TYPES > DATABASE STRUCTURES > DATABASEPERSON.
- Drag and connect a Create DatabasePerson step to the Start and End step.
- With the Create DatabasePerson step selected, navigate to the Properties panel > INPUTS > Item to Create field, and change its input mapping to Build Data.
- 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.
- 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 GenerationDespite 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.