+ Start a Discussion
lingannalinganna 

trigger on opportunity

hi

 

iam getting the below error   please suggest me.

thanks

 

Error: Compile Error: Invalid bind expression type of SOBJECT:Account for column of type Id at line 5 column 56

 

 

trigger score on Opportunity (after insert) {

for(Opportunity op:trigger.new)
{
account acc=[select id,score__c from account where id=:op.Account];
acc.score+=2;
update acc;
}
}

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,


Try the below code:


trigger score on Opportunity (after insert)
{
for(Opportunity op:trigger.new)
{
account acc=[select id,score__c from account where id=:op.Accountid];
acc.score__c+=2;
update acc;
}
}


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.