Sometimes we need to capture field updates for audit purposes. Here is an example:
Account form has a field for “Account Application Status” (Options – Approved/Rejected). In either case, we need to capture who approved/rejected the application and date/time.
My first idea was to implement this using business rules. However, this cannot be implemented using standard business rule functionality as it doesn’t support current date/time function. You can have a limited number of functions within business rule actions.
I was able to implement this via a combination of calculated fields and business rules. Here are the steps:
Capture date/time for a field update
- Create a new date/time calculated column in the Account table (“Calc_approved/rejected on”)
2. Add the calculation logic. Set the field value to current time.
Capture the current user who modified a field
- Create a calculated text column(Calc_approved/rejected by)
2. Configure calculated field as below:
These calculated fields will always capture the current time and current user of a form. Now all we have to do is set the business rules to update the tracking fields when the status changes.
BUSINESS RULES – Business rules are running on the UI actions therefore when a field is updated by the user, we can trigger a business rule. Since we already have current values coming in from the calculated fields, we can simply map the values in the business rule.
- Create a date/time field ” Approved/Rejected On”
- Create a text field “Approved/Rejected By”
- Add both these fields to the Account main form
- Go to “Account” table and navigate to Business rules tab
Approved/rejected date/time update rule
Configure the same action for the other branch. (Since we need to track the rejected date/time as well)
Approved/rejected user update rule
Create another business rule. Condition is the same as we are setting field values when the status field is getting updated.
Add the set field action and update approved/rejected by field with the value of calculated field.
Now save and activate both business rules.
Let’s test the form..
The form is now auto capturing approved time and approver name.
Considering data integrity, we can make these fields read-only so that users will not be able to change these fields manually.
In summary, what we did was to calculate current time and current user and assign those field values in business rule actions.
Hope this low code solution will help you in your design process.