+ 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.