This is a quick post to share a tip that I found to create a field to track changes to another field. Sure you can do it with a trigger and some code, but this is a no-code work-around.
I found this idea on Salesforce Idea Exchange here and modified it as I needed to. The reason to use this idea is that the History Tracking feature only tells you that the field has changed, rather than the field value has changed from x to y.
If there are just a few key fields that you need to do full audit tracking on, then this may be an option. I have set this up on Cases for the custom Case Response field – the field that contains the information as to what was done to resolve this Case.
Steps:
- In Cases, Add a new long text formula field called Case Response History.
- Create a new Workflow Rule called Append Case Response History or similar to do a Field Update on the Case Response History field
- The formula for the Worflow is something along the lines of this:
"Last Modified: " + LastModifiedBy.FirstName & ' ' & LastModifiedBy.LastName + TEXT(LastModifiedDate + 0.4167) + BR() + "------" + BR() +
PRIORVALUE( CaseResponse__c ) + BR() +
CaseResponseHistory__c
- You can play around with this formula, but I found this layout was good. The main components are that we are updating the Case Response History field with the previous value of the Case Response field, along with all the previous history that is already in the Case Response History field, then tagging it with the name and date of the update. I also have a line to divide each entry.
- The 0.4167 in the date formula converts UTC time to Sydney timezone. The default date format is a bit ugly, so you may want to do a lot more tweaking of this date field to change the format.
- The current value is in the Case Response field – this field only shows us what the previous value(s) were. The way I have set this up is that it shows the date that the current value was updated with the date/time and who updated it, in the history field. That way the next time the field is updated, that value will be listed with the date/time record of when it was updated. You need to test this out with a few updates to the field to see what I mean here (it makes sense to me, at least). If you don’t like this, then just modify the formula.
- Add the Case Response History field to the Cases Page Layout so you can see the audit history on the Case Record.
Notes:
- Beware: This is not entirely foolproof. The System Administrator or anyone with Modify All Data can edit the Audit field.
- This would probably be better as a hidden field that doesn’t take up space on the Cases form.
So, we needed a similar functionality and found the following changes needed:
1) You must create a long text field that contains the results of a workflow field update
2) The workflow field update contains the formula in the post above
3) The workflow criteria is Priorvalue(sourcefield) sourcefield
4) Workflow is set on every create or edit
With these modifications to the solution presented above, the audit field update worked like a charm without adding unnecessary content.
This is a cool idea and the Field Update logic you posted makes sense, but how did you setup the Workflow Rule itself? I found that my rule was triggering more than I wanted and I was getting LOTS of redundant data stored in the history field. There’s no obvious way to me to see if the field you’re tracking has actually changed or if it was some other field on the same object that got updated.
Thanks so much for this posting!!! Great creativity. This was so dang timely.Looking forward to more posts.