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

One Comment on “Salesforce Apex check field updated trigger

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 247 other followers

%d bloggers like this: