The code below show how you can use oldMap.get to get the previous value of a field after an update has been made in Salesforce. In this case I calculated how many days a specific date has been updated with:
trigger CaseOnParticularFieldUpdate on Case (before update) {
for (Case c: Trigger.new) {
Case oldCase = Trigger.oldMap.get(c.ID);
if (c.Field != oldCase.Field) {
// field was updated, do some magic here } } }
What about the relationship fields? How does someone compare those?