I have two standard objects



Each Quote may have one/more QuoteLineItems or maynot have any QuoteLineItems. Quote and QuoteLineItem are related with Master Detail Relationship. (Ranout of RollUp Summary Fields) QuoteLineItem has a formula field(percent type) called Gross_Margin__C. Quote has a custom field called Minimum_Margin__C.

I need a trigger on Quote(Parent) that will look at all of it's related QuoteLineItems(child records) Gross_Margin_c and returns minimum Gross_Margin__c on to the Quote record into the field Minimum_Margin_C.

Thanks in Advance

  • You might want to take a look at this Apex Library which makes writing such triggers easy, tgerm.com/2012/08/creating-easy-rollup-summary-fields-in.html, i have also wrapped this library in a packaged solution which automatically generates the Apex Triggers, andyinthecloud.com/2013/07/07/… Commented Apr 15, 2014 at 17:07
  • You can submit a case to Salesforce support asking for an increase in the maximum number of rollup summary fields. You need to explain your business need, and there is a hard max, either 15 or 20 per object; I don't remember. Commented Apr 15, 2014 at 17:09

1 Answer 1


Take a look at the roll up summary via lookup fields from Antony Victorio:


I've used this a number of times when a master-detail relationship with a standard roll up summary hasn't been an option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .