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
adiazadiaz 

Trigger to keep open opportunity owner unchanged

Hello,

 

Can someone share their code on how to keep the open opportunity owner after the account owner is changed? 

cloudcodercloudcoder

you can always retrieve the old value (the value of a field before a trigger executed) via the trigger.oldMap collection and then compare the new value against the old to determine if you want to do something in your trigger.

 

Check out the following docs:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm

 

In your case however, it may be easier to just make the field read-only for most profiles, or remove it from the page layout.