• Scottedt
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

So we have data miners that put in opportunities and they are "supposed to" change the ownership to the correct person.  But often this doesn't happen.  I could do multiple workflow rules to change the ownership to the correct person but they would require a lot of upkeep as turnover happens.  So I'm trying to create a trigger that would check to see if the Opportunity Owner does not equal the account owner and then make it equal the account owner.  This is what I have but it is throwing an error before I can even save.  Can someone please help?

 

trigger OpportunityOwnerUpdate on Opportunity (before insert,before update) {
//change the owner of an opportunity to be the owner of the account
// Declare the variable to hold the ID of the account owner
    ID MyOppId;
    Opportunity[] opp = Trigger.new;
    for (Opportunity o:opp)
    {
       if(o.Account!=null)
       {
           ID AccountOwnerId =[Select OwnerId from Account where Id=:o.Account__c].OwnerId;
           o.OwnerID = AccountOwnerId;
       }
   }  
}

 

Thanks,

Amanda

Hello,

 

Is it possible to change the contacts button Copy Mailing Address to Other Address at the contact object. I would like to change it so that with that button the Other Address of the Account to who the new contact is connected is copied instead of the Mailing address of the contact.

 

If its possible, how can i manage it?

 

With kind regards,

 

Christiaan