You need to sign in to do that
Don't have an account?
GuyClairbois
Retrieve differences between trigger.old and trigger.new
Hi all,
I was wondering if there is an easy way to retrieve a list of changed fields from an update-trigger.
I mean without going through each and every field and checking whether if changed or not. I need this for an e-mail notification of the changes done on a custom object. Otherwise, whenever I add, remove or change a field, the trigger has to be updated.
Many thanks,
Guy
All Answers
Hmm.. Dynamic Apex is not the simplest to use..
What I am trying now as a workaround is the following: I can access the record history from the VisualForce Email template, so there I can also easily retrieve the changed fields.
But when I trigger the Email directly upon a record change, the change is not yet reflected in the record history. I solved this by delaying the Email by a bit (Time-Dependent Workflow).
Only challenge is to retrieve a subset of the history (only the latest changes) in my <apex:repeat> loop when retrieving the record history. I solved this now by using the RENDERED tag for only displaying today's history entries (since these particular records don't change that often) but it would be better to have a filtering/sorting option in <apex:repeat>.
Let me know if you people have any other suggestions/additions.