CRM 2011–Generic Rollup Solution

Project Description

Many time we need to do the Rollup of certain child attribute data into parent attributes. For example number of Contacts for an Account or total order for order lines etc.

The best way to achieve this rollup is using CRM Plugins, however for each Rollup on each entity we have to write separate plugin which will take care of local attributes and type of aggregation required.

This Generic solution is meant to address this problem. It has generic code which works with configuration stored in CRM and can be applied to any entities.

This Generic Solution servers following purpose

1. It rollup data

2. Aggregation is done terms of Count, Average and Sum

3. A single Plugin Code is used for all the Entities.

4. Aggregation is completely configurable without any code change.

5. Aggregation changes in based on metadata.

How to configure Generic Rollup?

  1. Import the Managed Solution provided with this Project.
  2. If Settings does not reflect the entity link for “Rollup Configuration” entity, modify the customization to add the link to Settings (or any other Group).
  3. Create new record for “Rollup Configuration” entity
    1. At first enter the Child Entity Name and the type of aggregation and Save the Record (Do not close the Form)
    2. Once the record is saved under Rollup Config tab, enter the Configuration as follows
      1. Child Entity Entity Logical Name: this field will be auto populated based on what you have entered on main form.
      2. Child Entity Aggregate Attribute Name: This is the attribute from Child entity on which aggregation needs to be done. Note if aggregation type in Count then select the last items from this list which is PrimaryKey attribute name from Child Entity.
      3. Parent Entity Name (Lookup Attribute): This Dropdown contains all the Entities which has One-To-Many relationship with Child entity. Select Entity to which you want to update the aggregation results.
      4. Parent Entity Aggregation Attribute Name: This is attribute from Parent entity to update aggregation results.
    3. Hit Save once selection is completed and you are done !!!



What happens behind the scene?

Once you import the solution it also imports 3 plugin SDK Messages Processing steps, namely for Create, Update and Delete. These Plugin messages are configured to triggered on All the entities in CRM. Whenever the record is Created, Updated or Deleted this code checks whether rollup is configured for the entity. If yes it reads the configuration and calculates the aggregate values and updates it in Parent entity.


By default plugin will be triggered on all the entities irrespective of whether rollup is configured to entity, this can cause a performance problem. So in order to avoid Plugin triggering each entity, you can configured this messages separately for only those entities which need Rollup. This is extra admin steps that needs to be done, but it can give better performance.

Please try out the solution and let me know your feedback.


CRM Managed Solution is available on CodePlex

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s