Rows in a table are records in their respective data models. This tutorial describes how to add rows to tables and records to a database. This data can be used in the application.
Let's use a simple table as an example. It stores a list of tasks and markings on their completion.
The table has three fields:
- Name — task name in the string format.
- Date — the day the event should happen in the date format.
- Done — task state in the boolean format.
Create form
To allow users to add records to the table, create the input form.
To create a form, drag input widgets onto the canvas:
- Input (string) for the name field;
- Date picker for the date field;
- The done field must be equal to 0 when creating a new record, so it is set later directly in the BP.
Set up the inputs
Setting the Label so that the interface display what field this is.
Setting the Name to use input inside the business process.
Create Business Process
Next step — setting up the business process for the New task button that will save the data from the inputs.
The business process is set to the onClick trigger.
To get the values from the inputs that were created earlier, we need the Get Properties blocks. For the name field — the InputString Get Properties block, and for the date field — the Datepicker Get Properties block.
Now set the Component ID field in the Get Properties blocks.
For each field, set the name of the corresponding inputs.
The next step is to create a record. To do this, add the Make task <span>block. All the necessary values from the Get properties blocks must be passed to the Make task.
The make block does not write data to the database, it creates the entity locally within the BP. To save the record, the Server request POST /task/ block is required.
The done field is set to the default value in the Make task block.
Now save the records in the database. For this, the Server request POST /task/ block is used, where a record from the Make task block is added.
Video instruction:
It’s time to save and publish the project. Refresh the page to see results.