Chaining actions
Using Budibase, it's possible to create a sequence of actions. Below is a quick video 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 Name | Data Binding | Returns |
---|---|---|
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
- Save the query result to App state. Use the literal keyword to ensure an object is saved, and not text.
- Reference the metadata properties with the following Bindings:
### Status code: {{ State.QueryResult.code }}
### Response time: {{ State.QueryResult.time }}
### Payload size: {{ State.QueryResult.size }}
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
- In the /booking/new/row screen, delete the drop down for the leader, and replace it with a new text field. Type in the field name: LeaderName
- Next click on the 'Save' button and 'Define actions'.
Here you will need to add another 'Save Row' action underneath the existing one for the Leader table. This will allow you to create a new row for the leader entered into the in-line LeaderName field.
- Two columns overrides must be added.
The first Name{{ Form.Fields.LeaderName }}
saves the leader name as the value from our new LeaderName form field.
The second Booking column (the relationship field) is set to{{ Action 2.Saved row._id }}
. This represents the relationship id of the booking row that was saved in the previous action.
Continue if / Stop if
A chain of actions can be halted early on a condition.
In this example, you only want to save a row to a confirmed sales table given the item required payment.
If the queried item was free, then the chain of actions would be halted early before reaching step 3, or any further steps.
Alternatively you can achieve the same result with 'stop if' as follows:
Updated 9 months ago