In this article, we will explore how you can make the most of Knack's record actions in form views and grid views.
This article covers the following topics:
What are record actions?
Record actions are a specialized type of rule that empowers users to automate precise actions in the background when they submit a form or edit a grid inline in the Live App.
These actions have the capability to:
-
Update the record the view is using
-
Update connected records
-
Insert new connected records
Below are some typical use cases for record actions:
-
Track which user created or last updated a record.
-
Track the date and time a record was created or last updated.
-
Create a new receipt record when an order is submitted.
-
Change a record status when a field value is changed.
Tip: Record actions are a part of form views, so it will be helpful to be familiar with how to use this type of view. You can find a refresher on using form views here.
Note: Actions such as update this record, update connected records, insert a connected record, and send a custom email can also be triggered using Action Links.
See details in the Using Action Links article.
Managing Record Actions
Record actions are available on form views and grid views while inline editing. To add, edit, or delete record actions, you must first take one of the following actions: add a new form or grid, edit an existing form view, or enable inline editing on a grid.
Tip: You can learn more about form views and grid views here.
Adding a Record Action
To add a record action to your app, navigate to the "Pages" section of your Knack Builder, and select the form or grid view to open the view editor.
Adding a Record Action to a Form
After opening the view editor, navigate to the left toolbar and select "Actions & Rules". Then, choose the "Record Actions" section.
After navigating to the "Record Actions" tab in the view editor, simply click on "Add Rule" to successfully add your first record action.
Once you have added a record action, you can define its functionality. This involves specifying the action that will be triggered, determining when it will run, and identifying the values that the action will update.
Tip: For more information on record action settings, please refer to the section below.
Adding a Record Action to a Grid
Inline editing will need to be enabled before record actions can be added to a grid view. You can enable inline editing from the settings section of the view editor:
After enabling inline editing, you can conveniently add record actions to specific grid columns by modifying the column properties:
Note: Please note that at this time, record actions configured in Grid views to send a custom email will not have an email delivery history available. To learn more about email delivery history see our article here.
Editing a Record Action
To edit an existing record action, simply locate the form that the action is on in your Builder and open the view editor. From there, select "Actions & Rules" and then select "Record Actions".
Any record action settings can be edited for existing actions.
Deleting a Record Action
To remove existing record actions when editing a form view, simply click on the trashcan icon located in the top right corner of the rule.
Copying a Record Action
To make a copy of existing record actions while editing a form view, simply click on the copy icon located in the top right corner of the action.
Moving a Record Action
When editing record actions, you can rearrange them, which can be quite useful in managing multiple record actions efficiently. Simply click the icon highlighted below, and you can drag and drop the record action to the position/order you would like it to be in.
Note: Moving record actions does not change the order of execution.
Record Actions Settings
Actions: What can record actions do?
The first setting in a record action is called an "Action." This defines what Knack will do behind the scenes once the form has been submitted.
There are three action options:
-
Update this record
-
Insert a connected record
-
Update a connected record
Update This Record
This option will update the primary record the form is working with. This is useful for setting status or workflow fields on submission.
You can also assign logged-in users so that you can track who submitted a comment, rating, or ranking forms.
Examples:
-
Assign the logged-in user to the table's "Created by" field (a connection to a user role) so that you have a record of which user added the form.
-
Assign the "Submitted late?" Yes/No field the value of "Yes" when the form was submitted after a Due date field value.
Note: If your record action is configured to retrieve data from a connected record, but the rule appears to be ineffective, it is important to verify whether the record you are working on is indeed connected.
You can do this by examining the connection field of the record. If the field is empty, that indicates that the record is not connected.
See the following articles for using record actions to track what user updated records and when:
Update Connected Records
This option allows you to update records connected to the form's record. When adding this record action type, you will be able to select which connected table to insert a record into.
Note: Your form’s table must be connected to at least one other table for this option to be available.
For example, when a Line Item in an Order is changed, a record rule on the “Update Line Item” form can update the connected Order record’s “Last Updated” field.
Insert a Connected Record
This option adds a new record connected to the form’s record. When adding this record action type you will be able to select which connected table to insert a record into.
Note: Your form’s table must be connected to at least one other table for this option to be available.
This feature is particularly useful for seamlessly adding new notes to a project or creating a comprehensive version history of records that can be easily accessed within the Live App.
For example, upon submitting a form that edits a record, insert a new connected record of the same table with all of the same data, where the connection is called "Record History Entry". This way, you can track each change to the parent record with a separate record.
Tip: You can learn more about using record actions to set up a record history here.
When: When will a record rule run?
The "When" section of the record action defines the condition that needs to be met to trigger the action. When a form is submitted and all the conditions are met, the action will run.
By default, the action is set to run for every form submission. However, you can add criteria based on one or more specific form values.
You can trigger the record action "When" with different filters:
Filter |
Description |
contains |
triggers when the field contains the set value |
does not contain |
triggers when the field does not contain the set value |
is |
triggers when the field is a specific value |
is not |
triggers when the field is not a specific value |
starts with |
triggers when the field starts with a specific value |
ends with |
triggers when the field ends with a specific value |
is blank |
triggers when the field is blank |
is not blank |
triggers when the field is not blank and contains any value. |
has changed |
triggers when the field has been changed from its previous value |
has changed to |
triggers when the field has been changed from its previous value to a new specific value |
has changed from |
triggers when the field has been changed from a specific previous value to a new value |
Note: It is important to note that if you add multiple conditions, all conditions must be met in order for the action to be performed.
For example with a Task record, you may want to indicate whether it was completed on time. You can add When qualified to assign the "Submitted late?" Yes/No field the value of "Yes" when:
-
The status is Complete
-
The current date is after the Due Date on the Task
Values: What will a record action update?
The "Values" section of the record actions is where you set the field values that the action will apply. Here you can add multiple value settings by selecting the “+” button, or remove the settings by selecting the “-” button.
Values can be set to:
-
A connected value: Choose a field from a record connected to the form record. You can only set a connection field’s value based on another connection value, and it cannot be set to a name or auto-increment (ID) field.
-
A custom value: This allows you to either:
-
Enter a value manually.
-
Or you can append or remove values for multiple choice fields or connection fields without overwriting the existing values. (See more information below.)
-
-
A form value: Choose one of the form inputs.
-
To the logged-in user: This option is only available when the form is behind a login restricted to a specific user role.
-
To the current date: (For Date fields only) This option will set the Date/Time field to the current date.
-
To the user's current location: This option is for Address fields only, when the user is logged in, and when they have location services enabled on their browser.
Append/Remove Multiple Values
When using multiple choice fields or "many-to-many" connection fields with record rules, you can use the custom value option to either replace, append, or remove values from the field.
To use this option, select the "to a custom value" option in the "Values" section while building your record action. This will give you three options:
-
By replacing with: This option will replace the current field value with the values that are selected in the action when the action is triggered.
-
By adding: This option will append the value(s) selected in the action to any existing values in the field when the action is triggered.
-
By removing: This option will remove the value selected in the action if it exists in the field when the action is triggered.
Order of Execution
Record actions follow a specific order of execution when a form is submitted. It's important to note that all actions, including updating a record, inserting a connected record, and updating a connected record, run simultaneously on a form.
They do not execute in a top-to-bottom manner.
However, there are some exceptions:
-
Update this record actions are calculated before any record formulas or equations in fields. Therefore, if a record action depends on a formula or an equation, the record action will be calculated based on the previous value of that field.
-
Record actions for "Insert connected record" or "Update connected record" are processed after any formulas or equations in fields. This means that if a record action depends on a formula or an equation, the record action will be calculated based on the updated value of that field.
-
Emails will not be sent until all relevant record actions have been triggered. If you are experiencing issues with emails not being sent despite appearing to meet the necessary conditions, please ensure that record actions are not blocking the fulfillment of their field-specific requirements.
-
For example, an email will not be sent if it needs a Yes/No field's value to be "No", but a record action changes that value to "Yes".
-
Notes & Troubleshooting
-
Please keep in mind that when setting a connection field using a record action, you can only assign its value to another field connected to the record. Attempting to set it with a name or auto-increment (ID) field will not be successful.
-
If you are attempting to assign the logged-in user role but cannot find it as an option, please ensure that the login restriction allows the specific user role to access the page.
-
Equation fields' values can be used to set the values of other fields when inserting a connected record, but record actions that update the form's record can not currently use that record's equation fields' values to set the values of other fields on the same record.
-
Currently, record actions that are set up to send custom emails do not have access to an email delivery history.