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
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.
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.