Need to allow changes to only one specific field on an opportunity when at a certain stage.
How to efficiently determine within a trigger context that a only the specific field has changed and no other values have changed.
Salesforce's documentation on Sobject equality states that Sobject1 == Sobject2 will perform a field by field comparison of the two sobjects. Though my testing seems to indicate that Salesforce's is performing this field by field comparison with more fields than is returned by performing a metadata describe. As when I perform a metadata describe to get the Sobjects set of fields and iterate said set comparing the two Sobjects values I get a result indicating the two Sobjects are equal. Yet when I do the check of Sobject1 == Sobject2 it comes back false.
Does a trigger context Sobject(as in the Sobjects in trigger.new) contain extra values that would cause an equality check to fail despite all metadata describe visible fields being equal?
Conversely does a Sobject clone contain extra values that would cause an equality check to fail despite all metadata describe visible fields being equal?
Why would the following not result as being equal assuming only the Opportunity Type field has changed?
Opportunity oldOppClone = trigger.old.clone(true,true,true,true); oldOppClone.Type = trigger.new.Type; system.assert(trigger.new==oldOppClone);
Is there any other way to facilitate obtaining a set of fields which have changed between two Sobjects than metadata describing and iterating the fields and checking each individually?