You need to sign in to do that
Don't have an account?
linganna
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;
}
}
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.
All Answers
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.
ERROR:Variable does not exist: OpportunityId at line 9 column 21
trigger UpdateContactProductLabel on Opportunity (after insert, after update) {
List<Contact> contactsToUpdate = new List<Contact>();
for (Opportunity opp : Trigger.new) {
// Check if the Opportunity has a ContactId associated with it
if (opp.ContactId != null) {
// Retrieve the Contact related to the Opportunity
Contact contact = [SELECT Id, Product_Label__c FROM Contact WHERE Id = :opp.ContactId LIMIT 1];
// Update the Contact's field with the product label from the Opportunity
contact.Product_Label__c = opp.Product_Label__c;
contactsToUpdate.add(contact);
}
}
if (!contactsToUpdate.isEmpty()) {
update contactsToUpdate;
}
}