Press ESC to close

Creating easy rollup summary fields in salesforce

Rollup summary fields are pretty common requirement in customizations and app development. Rollups are easy to create on master-detail relationships as they are available as a field type. But on certain limits/situations we need to write apex code for rolling up the child information for common aggregations like COUNT, SUM, AVG, MAX/MIN etc, some of these limitations are

The ‘USUAL’ approach to handle this limitation is to either

  • Write trigger on various DML(reate, Update, Delete/Undelete) events on child sobject. These trigger either manually aggregated the information via Apex or used SOQL Aggregate queries for the same.

  • Write some batch/scheduled apex to perform this nightly.

I tried solving this problem by creating a small apex utility called “LREngine”. Complete description and details about it are available here on github:

Comments (2)

  • Anonymoussays:

    October 12, 2012 at 11:00 am

    I have used this utility and I simply say its AWESOME and SUPERB.But I think there is a one bug in your utility.When there is single record to delete from child .After deletion parent Rollup fields won't update and value remain same (only in case if one child record is present).Can you please confirm whether my understaning or finding is correct and if correct then can you please tell me the solution for the same.

Leave a Reply

%d bloggers like this: