This article will review setting up a version history for your records. This will track the User who made the edit, the date edited and the field values changed.
Scenario
You have forms that create and update records. You want to track when the date and time, as well as which user created or updated the record.
Requirements
Before setting up a version history for your records, you will need to have users enabled in your app. You can read more about getting started with users here.
Recipe
Create an Object to Track History
In the Data section of your builder, create a new object, let's call this object "Edit Log."
Once the new object is created, add the following fields to that new object:
-
"Edited by": A connection field, connecting to the User. Where each “Edit Log” record connects to one “User” and each “User” connects to many “Edit Log” records.
-
"Edit Date" - A date/time field, with time enabled.
-
"Object" - A connection field to original object you want to track. This will enable us to Insert a connected record from this object.
-
All of the original fields found in the original Object. You can either manually add the fields or copy them from the object you're creating the history for.
Add Record Rules to Update the Edit Log
Next we want to update the Edit Log object when forms are submitted in the live app. To do this, we will use record rules in the form view.
Navigate to the form you want to track updated from, and add the following record rule by editing the view.
Add Record Rule with the following settings:
-
Action: Insert a connected record: a new Edit Log record connected to this record
-
When: Every form submission
-
Values:
-
"Edited By": Set to the logged-in User
-
"Edit Date": Set to the current date
-
"Item Name": Set to the form value of Item Name.
- This is one of the fields found in the original object. Do this for all of the fields you're tracking.
-
Add a Table View for the Edit Log
Now you can add a new table view, showing the Edit Log records. In the example below, we add a table showing the Edit Log records connected to the Product object.
This table will then show all connected Edit Log records, when viewing a Product details.