Blogs
Keep up with the latest and greatest news, events and knowledge from the Magnetism team.
Free Trial
Experience your CRM 2013 30-day trial now!

Dynamics CRM Blog

Associate/Disassociate Message for Dynamics CRM 2011 Plug-ins

If you are a Dynamics CRM 2011 developer, you may have had issues when attempting to register plug-ins on the associate and/or disassociate message via the Plugin Registration Tool. This wasn’t a problem in Dynamics CRM 4.0, so why do many websites and blogs tell me that the associate and disassociate messages are no longer available in Dynamics CRM 2011?

We recently had a request to set the Name field of a custom entity based on Contacts which were associated with a record of that entity. The relationship between the custom entity and the Contact entity is N:N (many-to-many), so the associate and disassociate messages are required to set up this functionality via a plug-in. As we would normally do, we’d write the plug-in, fire up the Plugin Registration Tool and attempt to register our step on the associate message. However, we receive the following error:

Associate/Disassociate Message for Dynamics CRM 2011 Plug-ins

This error doesn’t make much sense. If there is an N:N relationship defined between our custom entity and the Contact entity, then we should be able to register this step successfully. Here’s how to fix it:

1. Open up the Plugin Registration Tool solution in Visual Studio. Note: The Visual Studio solution is available when you download the Plug-in Registration Tool from the Microsoft Download Centre. The .sln file is available in the following path: <drive>\Microsoft Dynamics CRM 2011 SDK\sdk\tools\pluginregistration

2. In the Solution Explorer, open up StepRegistrationForm.cs.

3. Use Find and Replace and search for “invalid primary entity or secondary entity”

4. Comment out the lines that include a message box with the error message that we encountered while attempting to register the new step.

Associate/Disassociate Message for Dynamics CRM 2011 Plug-ins

5. Run the Plugin Registration Tool in debug mode and attempt to register the step on the associate message again. The Plugin Registration Tool should crash on the following line:

Associate/Disassociate Message for Dynamics CRM 2011 Plug-ins

6. Stop the debugger and comment out the line where the Plugin Registration Tool crashed.

7. Run the Plugin Registration Tool again in debug mode and attempt to register the step on the associate message.

The problem should now be fixed! You will now be able to successfully register the step on the associate message via the Plugin Registration Tool. It is important that you restore the source code back to how it was originally because any existing or additional steps might have the primary and/or secondary entity set to “None”. This means that you might encounter incorrect plugin functionality as this can cause plugin steps to run on all entities instead of a specific entity.

  • Plugins
  • Microsoft Dynamics
  • CRM 2011


blog comments powered by Disqus