• Russell Maunder
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

Hi There, as the title says I am just starting to get my head around Apex and triggers. What I am trying to do is create a simple trigger on an Opportunity that will update the owner of that opportunity based on a custom field I have (Opportunity_Sector__c) regardless of who loads the Opportunity

 

So far I have this but I am getting an error:

 

trigger OwnerUpdate on Opportunity (before update) {

for (Opportunity o: trigger.new) {
if (o.Opportunity_Sector__c = 'Australasia'){
o.Owner = 'User Name';
    }
  }
}

 

 

error is 
Error: Compile Error: Illegal assignment from String to SOBJECT:User at line 5 column 1 

 

any help here on what I am doing wrong?

Hi There, as the title says I am just starting to get my head around Apex and triggers. What I am trying to do is create a simple trigger on an Opportunity that will update the owner of that opportunity based on a custom field I have (Opportunity_Sector__c) regardless of who loads the Opportunity

 

So far I have this but I am getting an error:

 

trigger OwnerUpdate on Opportunity (before update) {

for (Opportunity o: trigger.new) {
if (o.Opportunity_Sector__c = 'Australasia'){
o.Owner = 'User Name';
    }
  }
}

 

 

error is 
Error: Compile Error: Illegal assignment from String to SOBJECT:User at line 5 column 1 

 

any help here on what I am doing wrong?