function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mat KwokMat Kwok 

Last Field Modified

Hey guys,

 

Is there a way, through code or otherwise, to keep track of last field modified in addition to last modified date?

 

I was thinking of something in the trigger, but the only way I could come up with was to do a comparison of the old and new values of each field individually.

 

Thanks

 

EDIT: Scratch that, kind of irrelevant since you can edit multiple fields at once. Let me rephrase then, is there a way to find out what field(s) were edited via Apex?

flewellsflewells

Enable Field History for your object, select the fields you want to track (up to 20 per object) and you'll be able to see the history of changes to those fields.  Field History should track all changes to your selected fields, regardless of how the changes are made (i.e. UI, API, Apex).

Mat KwokMat Kwok

The problem is, we have more than 20 fields we need to track. And instead of seeing the history on every field that was changed, we just want to be able to see WHICH field was changed. If that makes sense.

flewellsflewells

You can probably get around the 20 field limit by contacting Salesforce.com Customer Support and requesting an increase, but that doesn't sound like it will really address your requirement. 

 

The only workaround I can think of is to setup one workflow rule and alert (or field update or outbound message, etc) per field.  Set it up to fire every time the record is created or edited and use the ISCHANGED function for your rule criteria.

 

For example, the rule criteria for custom field Name__c would be:

 

ISCHANGED(Name__c) && NOT( ISNEW() )

 

It would fire when Name is changed on an existing record and send an alert (or perform field update, outbound message, etc.)

 

Depending on the number of fields you have though, you could run into another limit -- up to 50 rules (workflow, assignment, auto-response, escalation) per object. See help topic "Salesforce.com Editions and Limits" for more details.