Registering Plugins on Many-to-Many relationships CRM 4.0

Im taking a step back in time today, back to 2009 and a problem that has arisen again for me today. Im trying to register a “Add” plugin event against a custom many-to-many relationship. Out of the box this isnt supported in CRM 4.0 (apparently it was omitted before release due to more testing needed).

There is a work around that has been out there for while from Aaron Elder I wanted to share.

Step 1) Backup up your CRM Database

Step 2) Run the following SQL script against your MSCRM database

-- ============================================================================
-- Enable Associate and Disassociate Plug-in Events Script v1.0
-- ----------------------------------------------------------------------------
-- (c) 2009 Aaron Elder
-- ============================================================================
-- This script is provided "AS IS" with no warranties, and confers no rights.
-- ============================================================================
-- While this is obviously "unsupported", I think the fact that these events
-- are not available is a bug and hopefully it will be fixed in a rollup.
-- ============================================================================

USE AscentiumCrmDev_MSCRM

-- Find the deployments SDK Filter ID for the
-- Associate and Disassociate Entity SDK Messages
DECLARE @DisassociateEntitiesFilterId uniqueidentifier
DECLARE @AssociateEntitiesFilterId uniqueidentifier
SET @DisassociateEntitiesFilterId = (SELECT SdkMessageId FROM SdkMessageBase WHERE [Name] = 'DisassociateEntities')
SET @AssociateEntitiesFilterId = (SELECT SdkMessageId FROM SdkMessageBase WHERE [Name] = 'AssociateEntities')

-- Enable the Associate and Disassociate Filters to be valid for custom processing
-- Custom Processing means "you register plug-ins against it"
-- Note: We only do this for the "generic" (OTC == 0) case, just to be safer
UPDATE SdkMessageFilterBase SET IsCustomProcessingStepAllowed = 1
       WHERE SdkMessageId = @DisassociateEntitiesFilterId AND PrimaryObjectTypeCode = 0

UPDATE SdkMessageFilterBase SET IsCustomProcessingStepAllowed = 1
       WHERE SdkMessageId = @AssociateEntitiesFilterId AND PrimaryObjectTypeCode = 0

Step 4) Recycle the CRMAppPool for CRM and open up your Plugin registration tool.

Step 5) Register a Step with the message “AssociateEntity” or “DisassociateEntity”. As expected the many-to-many bridge tables are not exposed in the entity list, so you just leave this blank.

Step 6) Now the obvious issue here is ALL many-to-many relationships in your CRM system will trigger off this plug-in as it cannot be entity specific. I did some digging and the easiest way to limit this to a single relationship is to check the Target input parameters. Typically you would be looking for entity name in the context – this does not exist for many-to-many. The next best thing is the relationship name which can be found here:

string relationshipName = context.InputParameters.Properties[“RelationshipName”];

Do a comparison to the name of your many-to-many relationship and proceed with your custom code if a  match is found.

From what I can see, CRM 2011 also supports the AssociateEntity and DisassociateEntity messages, so while this might be unsupported, atleast Microsoft have continuity in CRM 2011. I stress the code above is unsupported, use at your own risk.


, , , ,

Leave a comment

Where is the CRM 2011 Metadata browser?

People have been asking “Where is the metadata browser in Microsoft Dynamics CRM 2011?”. For those of you who don’t know what the original metadata browser was, see Metadata Browser. The original metadata browser was removed from CRM 2011.

I’m happy to announce that the latest update to the Microsoft Dynamics 2011 Software Development Kit (SDK) includes a managed solution that replaces and I hope improves upon the original metadata browser.

To read more check out Jim Daly’s blog over at Microsoft here.

, ,

Leave a comment

CRM 4.0 – Rollup 16 Released

A major CRM 4.0 rollup was released last week in the form of Rollup 16.

If you havent reviewed the fixes yet, visit the download site here.


Leave a comment

Microsoft Dynamics CRM 2011 Released for On-Premises and Partner-Hosted Deployments

Another milestone day in the Microsoft CRM world. Dynamics CRM 2011 has now been released for On-Premise and Partner Hosted Deployments.

Last month we saw the highly anticipated release of the CRM 2011 online. This release is a great addition and will really give customers the full range of options to best suit their needs!

Click here for the official press release.

Leave a comment

Dynamics CRM 2011 Developer Training Kit

Today Microsoft released the new CRM 2011 Developer Training Kit. Ive had a quick look through and there is a wealth of great content available.

Some highlights include WCF hand’s on labs, working with oData and LINQ queries & CRM and Silverlight introduction’s.

Download it here today, this may become the best go to resource for new CRM 2011 Developers!


Leave a comment

How worried should be about Microsoft’s cloud based CRM offering?

Here is an intersting write up on vs the newly released Microsoft Dynamic’s CRM 2011. CRM 2011 is being described as the proverbial 800lb gorilla in the midst of what will be an interesting year in the Online CRM Market.
Read more here.

Leave a comment

Microsoft Launches Microsoft Dynamics CRM Online Cloud Service Globally

REDMOND, Wash. — Jan. 17, 2011 — Microsoft Corp. (Nasdaq “MSFT”) CEO Steve Ballmer today announced the worldwide availability of Microsoft Dynamics CRM Online, the cloud version of the new Microsoft Dynamics CRM 2011 release that delivers new levels of productivity to sales, service and marketing organizations. The on-premises and partner-hosted versions of Microsoft Dynamics CRM 2011 will be globally available on Feb. 28, 2011.
Read more here


Leave a comment