After reading this article, you’ll know the following:
What the Create record step is and its purpose
How to use this step in your application
What is the Create record step?
Create record is a CRUD action step designed to add new records to a database. This step allows users to define and assign values to the properties of these records, using either static values or dynamic variables. By leveraging this functionality, users can efficiently manage and manipulate data within their applications.
In managing employee onboarding, when a new hire fills out their onboarding form with details like name, position, start date, and contact information, the Create record step in Betty Blocks can automatically create a new record in the Employee model.
This ensures accurate recording and storage of new employee information, allowing HR to access details easily and initiate further onboarding tasks like provisioning equipment or scheduling orientation sessions.
Options
Model: Select the model where the new record will be created.
Value mapping feature enables you to map new values to the properties of the selected record. These values can be either static, where you manually input the values, or dynamic, where you use variables. The new values provided will overwrite the existing values in the record.
As: Define the variable name for the new record. This variable can be reused in subsequent steps within the same action.
Variables: In this separate tab, you can add more variables to the step, which can be used for dynamic value mapping. This is particularly useful when the values that need to be assigned depend on other variables or calculations within your application.
Use case - Create form component
One of the easiest and most intuitive ways to use the Create record step in Betty Blocks is through the Create form component in Pages. Applying this component, users can quickly set up a form that captures and stores data in a specified model with minimal configuration.
To get started, simply drop the Create form component onto the Pages canvas. You will then be prompted to configure the form:
Select model: Choose the model where you want the data to be stored. For instance, if you are managing employee onboarding, you would select the "Employee" model.
Select properties: Specify the properties you want to include in the form. These could be fields like Name, Email, Start date, Active, etc.
The Create form not only generates the form fields but also automatically creates a new action with pre-configured values and the Create records step.
After setting up the Create form, navigate to the form's options and locate the action attached to it. Use the pencil icon to edit this action.
You'll notice that:
Start step, which passes the variables from the form to the "Create records" step, is already set up.
The fields in the Create record options are pre-filled with the form's values.
In the Finish step, there’s the result value picked up from the Create record step
Use case - Condition flow result
Another use case for the Create record step is within a flow that includes a Condition step. For instance, in managing email configurations, you can use the Condition step to check if an email configuration record exists in the database.
If it exists, drop the Update records step to the True flow to update the existing record with new values, which you fill in yourself in the Value mapping section (e.g., Port, Username, Password, Hostname). If it doesn't exist (Else flow), the Create record step creates a new email configuration record. This ensures that email configurations are either updated or newly created as needed.
In most cases, the Create record step is implemented via the Create form component on the front end, allowing users to fill out forms and have their data saved automatically. However, this step can also be used within other action flows, offering flexibility to manage data efficiently in various scenarios.