Chaining actions

Using Budibase, it's possible to create a sequence of actions. Below is a quick GIF demonstrating how to do this.

Action referencing

It can be useful to access data from a previous action in a new action.

The following actions expose data after execution:

Action NameData BindingReturns
Save Row{{ Action X.Saved Row }}Field value pairs (including auto-columns)

_id: Unique row identifier
Duplicate Row{{ Action X.Duplicated Row }}Field value pairs (including auto-columns)

_id: Unique row identifier
Execute Query{{ Action X.Query Result }}

First row example
{{ Action X.Query Result.data.[0] }}
{ data: [ <query-schema>_ ] }

_ An object as determined by the query schema
Trigger Automation{{ Action X.Automation Result }}The response of a Synchronous automation 🔒

Note X is the action number



Query result properties

In addition to the payload data of an execute query action result, you can also access the following additional information:

  • Status code - Number
  • Response time - String including the time unit
  • Payload size - String including the size unit

This can be useful in combination with Conditional UI for navigating to different screens upon an error, or to change text color based on the status code.

Example

  1. Save the query result to App state. Use the literal keyword to ensure an object is saved, and not text.
  1. Reference the metadata properties with the following Bindings:
### Status code: {{ State.QueryResult.code }}

### Response time: {{ State.QueryResult.time }}

### Payload size: {{ State.QueryResult.size }}
Response info returned after executing the query

Response info returned after executing the query



Tutorial: Creating and Linking two table entries in one form

Schema

  • Bookings
  • Leaders
  • One Booking -> One Leader

Use Case

Create a new booking and a new associated leader in one form


Steps

  1. In the Data tab, using the internal BudibaseDB, create a new table, "guides", containing the following columns - name (text), phone_number(text), email(text). Populate these with a few rows of dummy-data.

  2. Create another table, "tours", containing the following columns - destination(text) date(date, set to "Date only").

  3. In the tours table, add a column called "guide", with a relationship of many rows in tours to one row in guides. Set the column name in the other table to be "tours".

  4. Switch back to your guides table to see that the relationship column has been created. The overlapping circles denote that this column is a relationship to another table.

  5. Head to the design tab, and in a new screen, add a form component (not to be confused with a Form Block). Set the form component to create a row in the tours table.

  6. Add a Text Field component to your form, and set the name as "destination" and the label as "Tour Destination"

  7. Repeat the previous step until your form has all of the following

FieldNameLabel
Text FielddestinationTour Destination
Date FielddateTour Date
Text FieldTGnameTour Guide's Name
Text FieldTGphoneTour Guide's Phone Number
Text FieldTGemailTour Guide's Email Address
  1. Next, add a button as a child of your Form Component - Set the text to "Save" and (optional) add an Icon

  2. Add an On click action to the button: Validate Form will catch any "required" fields, as well as any custom validation set on a per-field basis (though not applicable in this guide).

  3. Add another action - Save Row. Select your form as the datasource, and set the table as tours. Add two columns from the tours table, destination and date, and assign the values from the destination and date fields accordingly.


  4. Add another Save Row action, but this time we will save the Tour Guide's information to the guides table. Look closely at the fourth column - tours - this is saving row_id from the previous action, which is linking the two rows together. This action will save a new tour and a new guide, and show the relationship between them.

  5. (optional) Check the "Do not display default notification" on one of the Save Row actions.

  6. Add a "Clear Form" action to reset the form back to it's default values

You could also use a "Navigate To" action to take the user to a screen showing the information in a table, or back to the homepage.