function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jpwagnerjpwagner 

Understanding Execution Governors

I'm not entirely clear on the limits that scale with trigger batch size. 
 
So I would like to pose a question and ask the community if there are any nifty work arounds or other ways to achieve a certain type of task.  (Although I secretly hope I misunderstood the limits...)
 
Let's suppose I have a field on the OpportunityLineItem that indicates the Product Family from Product2 and I've set up 2 triggers to write to that field (one on OpportunityLineItem before insert, and one on Product2 before update.)  So far so good.
 
Now if I have a single ProductId that I reference in 101 different OpportunityLineItems, then if I change that Product's Family, my trigger on Product2 will fail.  Is this correct?
 
Similarly if this Product was on 1,001 different OpportunityLineItems, I could not even see that list of OpportunityLineItems that reference it (from my select statement.)
 
If this is a correct understanding, what can be done to get around this (another method or a way to batch the results in 100s or 1000s)?  Products are often added to many more than 100 OpportunityLineItems, so if this is a correct understanding, I'm not sure I understand the purpose of this limitation.
 
Thanks!
 
jpwagnerjpwagner
*bump
jpwagnerjpwagner
*bump
jpwagnerjpwagner
*bump
TehNrdTehNrd
Just so I understand clearly. When a opp line item is inserted you get the product family from the product2 object and apply it to a field on the line item. This works.

But you also want a trigger on the product2 object that when ever the Product family is updated go back and update the opp line items with the new values.

The first part seems doable. The second part not so much as you will probably have to update thousands of lineitems and the governing limits won't let you. We, for example have over 300K opplineitems. For a trigger to process these it would take a long time, alot of resources, and the UI would appear to freeze while the opperation is performing.
jpwagnerjpwagner

This is not clear:  what makes it not doable, (1) the governing limits or (2) the time it takes.

 

I would just like someone to give examples of when the governing limits are exceeded and when they are not.  I think the wording in the Language Reference is unclear.

 

Thanks.

SuperfellSuperfell
The govener limits won't let you do it in a trigger. Denormalized data models are generally not a good idea, and triggers were never meant as tool for you to be able to denormalize your data model.