When an app has numerous users, it may become necessary to track who created a record or last updated a record. By combining connections with logins and record rules, you can automatically log which user record last updated a record.
You have an app for managing sales leads. Your team of Sales Rep users is constantly updating lead records. You want to track which user last updated a lead.
The following are requirements for adding this recipe:
Your database has an object that stores records you want your users to update. In this example, these are leads.
Your app has user logins activated. The settings allow you to have logins for different user roles.
You have a page protected with a login for your users to log in and access. This could be a user role, like Sales Reps in this example.
Your page has a form that either adds or edits a record.
Add a Last Updated By connection field
From the Data section of your Builder, click on the object where you want track the Last Updated By; in this example it is a Leads object.
Last Updated By needs to be a connection field to the user role that submits the forms. Add a new connection from the right panel in your object. When prompted to select the object, select the user role you would like to track; In this example it is a Sales Rep role. The relationship type should be one-to-many.
Add a record rule to automatically update the connection field
From the Pages section of your Builder, find the page that contains the form the users use to either add or edit the record.
Click on the "Form Rules" tab, then select the “Record Rules” tab. Add a new rule by clicking the “Add Rule” button.
For every form submission, this rule is going to update this record and set the value of Last Updated By to the logged-in Sales Rep.
The rule you just added applies to this form only. If you have other forms where your users add / edit records, you will need to add the same rule to those forms as well.
Knack Tip: If you don’t see the logged-in role option, it means that the login for this page does not allow that specific role (Sales Rep) to access the page. Update your login view and make sure the Sales Rep is allowed to access this page.