top of page
Search

Capture "Created by" and "Created when" in a Knack Database App

Writer's picture: Dave ParrishDave Parrish

Updated: Jul 25, 2024




Hey folks! David Parrish here from Knack Builders, bringing you another helpful video on Knack functionalities. Today, we're talking about powerful feature: how to capture when a record was created and who created it. Whether you're managing invoices, tracking customer interactions, or overseeing project entries, this feature is invaluable for keeping tabs on your data.


Let’s break this down step-by-step so you can implement this functionality in your own Knack applications.


Getting Started: Why Track Record Creation?

Before we jump into the details, let’s discuss why capturing creation and modification data is so important. Knowing who entered a record and when it was created can help with accountability, auditing, and tracking changes over time. This is especially useful in systems dealing with sensitive or critical information like invoices or custom orders.


Setting Up: Tracking Record Creation

We'll start by creating a simple setup to track who created a record and when. I’ll be using a sample app called "Requisitions" for demonstration.


  1. Create a Connection to User Accounts:

  • First, you'll need to create a connection between your "Requisitions" object and the "Accounts" object. This allows us to link each requisition to the user who created it.

  • In the "Requisitions" object, add a connection field to "Accounts." Choose a one-to-many relationship, as each requisition will be linked to one user, but each user can create multiple requisitions.

  1. Add the "Entered By" Field:

  • Rename the connection field to "Entered By" to make it clear that it captures who created the record.

  • Add a "Date" field to capture when the record was created. Set this field to default to the current date. If you want to track the exact time, you can include a time component as well.

  1. Configure the Form:

  • When a user adds a new requisition, you don’t need them to manually select who created it. Knack’s "logged in user" functionality will automatically populate this field with the currently logged-in user.

  • In the form settings, go to "Record Rules" and set up a rule to update the "Entered By" field with the logged-in user’s details.


Adding Modification Tracking

Capturing who last updated a record and when it was updated involves a few more steps:


  1. Add a "Last Updated By" Field:

  • Similar to the "Entered By" field, create a new connection to the "Accounts" object but name it "Last Updated By."

  1. Create a "Last Updated Date" Field:

  • Add a date field to track the last update date. This field will be initially set to "no value" or blank when the record is created.

  1. Update Tracking Logic:

  • When a record is edited, you’ll need to update the "Last Updated By" and "Last Updated Date" fields. This ensures that every time the record is modified, you capture the details of the person who made the changes and when they did so.

  • Be cautious with updates: If users submit changes without altering any content, you might inadvertently update the "Last Updated" fields. To handle this, you may need additional controls or specific conditions for updating these fields.


Advanced Tracking: Maintaining a History

For those looking for more detailed tracking, such as keeping a history of all changes to a record, you can set up a separate "Requisition History" table:


  1. Create a History Table:

  • This table will store records of changes, including who made the change, when it was made, and what the change involved.

  1. Link History Records:

  • Use a connection field to link the history records back to the main requisition record. Each time a record is created or updated, you’ll insert a new entry into the history table with details about the change.

  1. Show History on the Interface:

  • You can configure your user interface to display the history of changes, giving you and your users a clear view of the record’s evolution.

Pro Users: Accessing Detailed Records

For those using Knack’s Pro features, you can access detailed history records through the backend. This feature allows you to view who made changes, when, and what was altered. While this is excellent for troubleshooting, it may not always be the most user-friendly option for quick checks.


Wrapping Up

So there you have it—a straightforward guide to tracking when and by whom records are created and updated in Knack. Whether you’re managing simple forms or complex workflows, this feature is a powerful tool for maintaining transparency and accountability in your data.


If you found this guide helpful, please like and share it! Feel free to reach out with any questions or for more in-depth assistance. Thanks for tuning in, and happy tracking!



You can check out my Knack database services here:  https://www.knackbuilders.com/knack-database-consulting


Interested? Book an intro call: https://calendly.com/daveparrish/callwithdave

22 views0 comments

Recent Posts

See All

Comments


bottom of page