You need to sign in to do that
Don't have an account?
XIO
Need trigger to only fire for specific opportunity recordtype
Hello,
I need help with the apex trigger below. I need this trigger to only fire for Opportunity RecordTypeId '01250000000HjVU'
Any assistance is greatly appreciated!!
I need help with the apex trigger below. I need this trigger to only fire for Opportunity RecordTypeId '01250000000HjVU'
Any assistance is greatly appreciated!!
trigger AttendeesHandling on Opportunity (after insert,after delete,after update) { list<Id> rlist1=new list<Id> (); list<Product2 > rlsit=new list<Product2>(); //////////// insert and update operation if(trigger.isinsert || trigger.isupdate){ for(Opportunity o : trigger.new) { rlist1.add(o.Discount_code_LU__c); } Product2 p2=[select id,Attendees__c from Product2 WHERE id in:rlist1]; for(Opportunity opp:trigger.new){ p2.Attendees__c=opp.Attendee_Name__c ; rlsit.add(p2); } update rlsit; } /////////////// Delete operation start if(trigger.isdelete){ for(Opportunity o : trigger.old) { rlist1.add(o.Discount_code_LU__c ); } Product2 p2=[select id,Attendees__c from Product2 WHERE id in:rlist1 LIMIT 1]; for(Opportunity opp:trigger.old){ p2.Attendees__c=opp.Attendee_Name__c ; rlsit.add(p2); } update rlsit; } }
Please check once below code.
In place of Recoedtypelabelname give your recordtype lable name.
Please check once and let me in case of any help.
Thanks
Varaprasad
All Answers
Please check once below code.
In place of Recoedtypelabelname give your recordtype lable name.
Please check once and let me in case of any help.
Thanks
Varaprasad
Thank you for your reply!
I'm still getting the error below when I try to update the other opportunity recordtypes. The trigger works great for the recordtype 'Conference' but it gives an error for the other recordtypes. I want the trigger to work for the opportunity recordtype 'Conference' ONLY. The trigger shouldn't fire for any other recordtype.
Error:Apex trigger AttendeesHandling caused an unexpected exception, contact your administrator: AttendeesHandling: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: ()