Rollup Functionality for Custom Entities in MS Dynamics CRM 2011 and MS Dynamics CRM Online

Visit Website View Our Posts

I recently had an interesting situation with one of our clients who wanted to use a custom entity modeled on the Accounts entity to view their customer data. The difference was that this entity would have a N:N Relationship with Contacts instead of a 1:N relationship; however they still wanted to be able to view a rollup of all the Activities and Opportunities from the related Contact and Opportunity records on the custom entity form (see the class diagram below).

Now, CRM makes it really easy to view that for Accounts using the Associated Views, but the same cannot be said for custom entities. There were a couple of different options coming to mind that I knew would achieve the effect: for instance, creating a SSRS report to pull out all the Activities and Opportunities associated with the related Contact and Opportunity records for a particular custom entity record.  Another option would include using JavaScript with Silverlight. The catch though, was that the client wanted to have all the records appear in a standard grid on the entity form.

So I did some research and found an article that explains a plugin to handle the RetrieveMultiple message. However, this article was written for CRM 4.0 which is significantly different from our target CRM version CRM 2011 or CRM online.  To make it work for the new version, I rewrote the code and utilized the streamline development toolkit provided in CRM SDK 5. The experiment proved successful and I thought it would be helpful to share the solution with other CRM developers out there. Here’s a step by step breakdown of what I did:

Step 1. Create Dynamics CRM 2011 Package project and connect to CRM.

Step 2. In CRM Explorer, right click on the custom entity and select Create plug-in.

Step 3. In the Create Plug-in dialog, select values as below. CRM SDK tool kit will automatically generate a CRM plugin project and the structural code. You just need to implement the PreActivityRetrieveMultiple function as described in the next step.

Step 4. Implement PreActivityRetrieveMultiple function as below. Some code has been omitted.


Step 5. Build and deploy the project. With CRM developer toolkit, you can deploy CRM plugin or custom workflow activity within Visual studio.

Step 6. Test the plugin. Verify the activity associated view in the custom entity. In the standard activities associated view of the custom entity, you should be able to see the activities from child contacts and child opportunities.

 As some might already have noted by now, one of the downsides of working with the CRM SDK 5 is that it’s quite different from previous versions and some components in the previous versions are no longer supported or are changed, which can often frustrate the developer.  However, I feel that it does streamline the development process of CRM plugins and custom workflow activities and can help to improve the development productivity. Developers can also make other CRM developments and customizations within Visual Studio.

1 thought on “Rollup Functionality for Custom Entities in MS Dynamics CRM 2011 and MS Dynamics CRM Online”

  1. Could you please update this code to include the omitted sections? Specifically, I am not sure how the last piece, "add all child entities into the link criteria for the execution context" works to return this updated list to the view.

Comments are closed.

Show Buttons
Hide Buttons