Salesforce Apex check field updated trigger

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: { 
Case oldCase = Trigger.oldMap.get(c.ID); 
if (c.Field != oldCase.Field) { 
// field was updated, do some magic here } } }

One thought on “Salesforce Apex check field updated trigger

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s