You need to sign in to do that
Don't have an account?

Opportunity vs. OpportunityLineItem
I'm writing a trigger that will cause some data updates to happen when an Opportunity has certain products added or changed.
I think the trigger should run on Opportunity (after insert, after update), but I can't seem to access data like Opportunity.OpportunityLineItem[x].productName when triggering on the opportunity.
If OpportunityLineItems aren't a child of Opportunity, how does one access that data? I guess I'm not approaching this correctly and don't understand the Opportunity object yet.
Thanks,
Kevin
couple of things to clarify for you:
1. you can query the opplineitem
for(OpportunityLineItem oli : [select Id from OpportunityLineItem where OpportunityId in : listofoppidsintrigger]){
//...dostuff}
2. that's more for reference, because based on your use case ("when certain products are added") you want this trigger on the OpportunityLineItem
clear?
Ah ha... many thanks. This makes more sense now.
It hadn't occurred to me that the OpportunityLineItem isn't a part of an Opportunity at all and that I need to run the trigger on OpportunityLineItem.