You need to sign in to do that
Don't have an account?
aj2taylo2
Apex Class - Compare Old vs. New Values
I have a custom class that is updating a list of records.
Is there a way for me to iterate through the list to determine if a particular field has been updated before/after update?
public PageReference mySave() { update this.myRecords; for(Object__c o : this.myRecords) if(o.myField__c <> [oldvalue].myField__c) {do something} }
I know how to accomplish this in a trigger, but I only want to execute this change check within my controller, not globally for all record updates.
If you want it done only in a Visualforce page, you'll just need to clone the original record:
All Answers
I've not gone through your detailed requirement however....you can use Trigger.old & Trigger.new....by calling this class from trigger.
OR
If requirement can be achived by writing a Validation/WF formula...you can use priorvalue() function
If you want it done only in a Visualforce page, you'll just need to clone the original record:
Thanks sfdcfox; someone else suggested this to me as well, and it got me the result I wanted!