This article will review setting up a version history for your records in your Knack app.
This article covers the following topics:
Overview
This article aims to guide you through the process of setting up a version history for your records. By following this guide, you will gain insights into the setup of this workflow and be able to implement it in various scenarios of your own.
Use Case
If you have forms that generate and modify records, it is important to keep track of the date and time, as well as the user responsible for creating or updating the record. This is possible by enabling the record history feature, but the data will only be available from within the Builder.
This guide will provide a guide to set up a version history for records that can be viewed by your app users within the Live App. Admins can log in to manage equipment inventory, view which employees have borrowed which equipment, and view a log of all previous checkouts for an item.
Requirements
Before setting up a version history for your records and following along with the steps in this article, you will need to have users enabled in your app. You can learn more about getting started with users here: About Users
With this use case, we will also be utilizing record rules. You can learn more about record rules here: Using Record Rules
For a more general overview of everything you need to know about using the Builder, see our Builder Guide section of our learning center.
Steps
Tip: For these steps, we'll be building out the Equipment Tracker template app. Feel free to follow along by utilizing the template.
1. Creating Your Data Tables and Enabling Users
To begin, we'll want to ensure that we have users enabled in the app. To learn how to enable users, see our article here: Activating Users
Once users are enabled, we can add two user role tables:
-
"Employees": Employees will login and return/borrow items
-
"Supervisors": Supervisors will login and can view each item's log history
After that, we can add a non-user role data table named "Items" and another data table named "Logs":
2. Adding Fields to Your Data Tables
Next, we can add the appropriate fields needed for this use case in the Items and Logs tables.
Tip: To learn more about fields, see the following articles:
To start, we will add a connection field in the Items table that connects to the Employees user role table. This connection will be a one-to-many connection type:
Then, in the Logs table, we'll also need to add two connection fields:
-
"Library Item": Where each Log record can connect with one Item and each Item record can connect with many Log records
-
"Employee": Where each Log record can connect with one Employee record and each Employee record can connect with many Log records
In the Items table, we'll need the following additional fields:
-
Short Text field named "Item"
-
Paragraph Text field named "Brief Description"
-
Short Text field named "Item Number"
-
Yes/No field named "Available"
- Date/Time field named "Date"
- Multiple Choice field named "Action"
- Options: Borrowed & Returned
- Paragraph Text field named "Comments"
3. Building Out Your Pages and Views
We'll now navigate over to Pages to begin setting up our Logs view to enable users to see Log records of each record update.
From the "Home" page, we'll see a grid view of Item records that the logged-in user has in their possession and a button to return the item. Below that, there is another grid view with available Item records that can still be borrowed by the logged-in user with a button to select to mark the Item record as borrowed.
Each of those buttons triggers a modal pop-up to appear with a form view to submit any comments the user may have:
Submitting either the "return" or the "borrow" form then creates a Log record that supervisors can view from the Supervisor Dashboard > Edit Library Item child page:
Now that we have explored the construction of this template app with its various pages and views, let's delve into the configuration of the Logs grid view on the "Edit Library Item" child page:
Since the Logs grid view exists on a view details page that shows record data for a specific Item record, we're able to configure the grid to display Log records connected to the page's Item:
Supervisors can now utilize the grid view to access a detailed history of each instance when the library item they are currently reviewing was borrowed or returned by an Employee. The grid displays the date of the event, any accompanying comments, and the employee responsible for the borrow/return log submission.
Feel free to experiment with this workflow on your own and, if it aligns with your specific use case, implement it across multiple apps to establish a version history for your data! 🚀