Record Rules
Record Rules
Record Rules are a type of automation found within a Form Component. You can create Record Rules to automatically update records, as well as insert new records once a form is submitted.
Record Rules automate records and tasks within forms similar to how Action Links automate records and tasks within tables, lists, kanbans, etc.
Adding record rules
When creating a new record rule, you will select the action, the condition for when the action should take place, and the field values you wish to set for when the action occurs.
For instance, you can create a record rule that whenever a Note record is created through a Form Component, automatically set the date and time for when the note was created to the current date and time.
To create this record rule:
Then, create the record rule to update this note record (the Action), always (the When/Condition), by setting the Date/Time Created field to the Current Date and Time (the field values to set):
Now, when users add a new note, even though there is no Date/Time Created field on the form, the note will automatically be saved to the current date and time to which it was added.
Please Note: Every time this form is submitted, even if the field is present in the form, it will be overridden by the record rule.
Record rule actions
When creating a new record rule, you can choose one of the following four actions:
-
Update this record
-
Update connected record
-
Insert connected record
-
Insert new record
Let's explore each type of record rule action.
Update this record
Creating a record rule with the update this record action will automatically update the current record once the form is submitted with the custom-defined values you set based on the custom-defined conditions you set.
For instance, you can create a record rule that when the order form is submitted, automatically update this order record when the Order Date is over 180 days by setting the Order Status to a custom value of Archived.
In this example, the action is "update this record", the condition is when the "order date is before the previous 180 days", and the field values to set are to set the "order status to a custom value of Archived".
Tip: A simple way to view and understand a record rule is to simply read the entire section as a sentence. For instance, "Update this record when the order date is before the previous 180 days by setting the order status to a custom value of Archived."
This record rule will run automatically once the form is submitted and the rule's conditions are met.
You can add as many conditions and field values to be set as you need for a single record rule. For instance, you can create a record rule to update this order record when the order date is before the previous 180 days and the order status is not Open by setting the order status to Archived and the Last Modification Date to the current date and time. Click on the + icon to the right of the first condition and field value to add these additional conditions and field values.
When setting the field values to be updated for this record, you can choose from several field value options, depending on the field type selected.
Depending on the fields selected, you can choose from the following field value options to update this record:
-
Custom Value - Choose a static value that will be used every time the condition is met.
-
Set Blank Value - This will null the value.
-
Form Value - Use the value from another field in the form to update this particular field's value.
-
Connected Value - If this form's data table has a connection to a parent data table, you can use a value from the parent data table to update this field's value. For instance, if you are adding a task that belongs to a project, you can use a value from the projects data table to update this task.
-
Logged in User's Field - Use any field which belongs to the user who is currently logged in and is adding/editing this form. For instance, when adding a new job you can retrieve the value of the logged-in technician's license number and update this job record with that value.
- Auto-logged user- If the field being updated is a connection field to the Users data table, you can set this field value to be auto-saved to whoever is logged in.
- Current Date & Time- When selecting date and time fields, you can update this record's date and time to the current date and time that this record was submitted.
Update connected record
Creating a record rule with the update connected record action will automatically update a connected record of your choosing once the form is submitted with the custom-defined values you set based on the custom-defined conditions you set.
For instance, say you have a Project Management App with two data tables:
- Projects data table
- Tasks data table with a connection field to the Projects data table (each task belongs to a project).
The following image illustrates the connection between these two data tables where each task belongs to a specific project.
Now, say that anytime you add a new task and assign the task to a project, you want to automatically update the connected project's record and set the Last Task Added field to the current date and time.
You can accomplish this by creating a record rule within the Add Task Form to update the connected Project record and set the Last Task Added field to the current date and time that the task is submitted.
Now, when a user adds a new task and assigns it to a project, that connected project record will be automatically updated to show the Last Task Added field as the current date and time that this task was added.
This update to the connected record will occur automatically once the form is submitted.
Insert connected record
Creating a record rule with the insert connected record action will automatically insert a new connected record of your choosing once the form is submitted with the custom-defined values you set based on the custom-defined conditions you set.
Inserting a connected record will automatically add a new record to the connected data table as well as establish a connection for the new record between the current data table and the connected data table using a connection field that you specify.
For instance, say you have a Health Services App with two data tables:
- Clients data table
- Tasks data table with a connection field to the Clients data table (each task belongs to a client).
Now, say that when a user adds a new client with a high-risk assessment, you want a new task to be automatically inserted into the connected Tasks data table called "Conduct initial in-home assessment" and a connection to be established between this new task and this new client.
You can accomplish this by creating a new record rule within the Add Client Form to insert a connected task record when the new client's risk assessment is high and set the task name to a custom value of "Conduct an initial in-home assessment".
Now, when a user adds a new client with a high-risk assessment, a new connected task will automatically be inserted within the connected Tasks data table called "Conduct an initial in-home assessment".
You can create as many conditions and values as you need for each record rule. For instance, you can add a condition to insert the new connected task when the client's risk assessment is high and the client's age is above 70 and to set the task name to "Conduct an initial in-home assessment" and the date the task was added to the current date and time.
Insert new record
Creating a record rule with the insert new record action will automatically insert a new record of your choosing once the form is submitted with the custom-defined values you set based on the custom-defined conditions you set.
The insert new record action is generally most useful for logging data that is not connected so that even if the current record is deleted the log/note detailing this record will not be orphaned.
Therefore, it is recommended to avoid using connected fields within an insert new record rule, and rather use regular fields, so that even if the current record is deleted the new note/log record will not be orphaned.
For instance, say you have a Clients data table and a Notes data table, and every time a user adds a new client you want to automatically insert a new record into the Notes data table to log the details of when the client was added to the database and by whom.
You can accomplish this by creating a record rule to insert a new note record within the Notes data table every time a new client is added and set the note fields to log the details of when this client was added to the database and by whom.
Now, every time a user adds a new client, a new note will be automatically inserted within the Notes data table logging when this client was added to the database and by whom.
Since this record rule uses an insert new record action (rather than an insert connected record action), even if this client record is ever deleted, the new note logging this client will not be orphaned.
To successfully use the insert new record action and avoid ever orphaning the new record from the current record, it is important to not use connected fields within an insert new record rule. For instance, instead of using an Added By connection field to the Users data table, it is recommended to use a basic text Added By field and set the new note value to the Logged-in User's Name Field. This is because using connection fields can orphan the new record's fields should the current record ever be deleted, whereas using regular, non-connected fields will ensure that the new record's fields will not be orphaned should the current record ever be deleted.
Record rule values
Once you specify the action and condition(s) for a record rule, you can specify the field values that you wish to be set when the record rule runs.
Field value options depend on the field type selected. For instance, if you specify to set the Job Date field when the record rule runs, date-related value options will be available to select for this date field.
Depending on the fields selected, you can choose from the following value options to apply when the record rule runs:
-
Custom Value
-
Set to blank
-
Form Value
-
Connected value
-
Logged in user field value
-
Auto Logged User (when the field is set in a connection to the User’s table)
-
Current date/time (when the field is set is a date or time field.)
Let's discuss each value option.
Custom value
Choose a static value that will be used every time the condition is met.
The custom value options will be dependent on the type of field selected:
- Date/time fields can only have a custom value of a date and time
- Text fields can be any custom text value
- Connection fields must be a predefined connected record.
- Option fields can be any option from the list of options in that field
Set blank value
This will NULL the value.
Form Value
Use the value from another field in the form to update this particular field's value.
Connected value
If the form's data table has a connection to a parent data table, you can use a value from the parent data table to apply to this field's value. For instance, if you are adding a task that belongs to a project, you can use a value from the projects data table to apply to this task.
Logged in user's field
Use any field which belongs to the user who is currently logged in and is adding/editing this form. For instance, when adding a new job you can retrieve the value of the logged-in technician's license number and apply that value to this job record.
Auto logged user
If the field being updated is a connection field to the Users data table, you can set this value to be auto-saved to whoever is currently logged in.
Current date and time
When selecting date and time fields, you can save this record's date and time to the current date and time that this record was submitted.
If you save a value to the current date and time, keep in mind that the timezone in your app will be used for this date/time value. Be sure that the timezone in your app is set correctly. Click here to learn more about setting your time zone.
We'd love to hear your feedback.