Dynamics CRM Upgrade Blocker: Orphan Plugin Step Image records

Last week I was working with another Microsoft partner who was upgrading a customer’s Dynamics CRM from 2011 to 2015 when they ran into the following error moving to Dynamics CRM 2013 (which you must do, to get to 2015):

image

Note: SdkMessageProcessingStep is the internal name for a plugin step, as configured using the Plugin Registration Tool.

So we ran the following script to see if we could not locate the offending SDK Message Processing Step.

SELECT 
 SdkMessageIdName,
 Name,
 EventHandlerName,
 SdkMessageProcessingStepId
FROM
 SdkMessageProcessingStep
WHERE
 SdkMessageProcessingStepId = 'd987ac98-8b85-dd11-b48e-001143ec27a2'

And we got nothing.

This is very strange so I started looking around for anything else that could cause such and error – and I actually found it.

Root Cause

The issue was actually on a separate tabled called: SdkMessageProcessingStepImage, which stores the Pre or Post Image configuration for a specific plugin step.

This CRM system was originally v4.0 and somewhere in the upgrade to CRM 2011 a plugin step was removed from the system and the Plugin Registration Tool did not remove the associated Plugin Step Image, so these records remained in the database, unused and unnoticed until the upgrade process tried to modify them.

The actual error message is displayed because the SdkMessageProcessingStepImage is referencing the SdkMessageProcessingStep, which doesn’t exist-just like the error says.

Correcting the Issue

To verify this is indeed the problem, we ran this script:

SELECT 
  *
FROM
  SdkMessageProcessingStepImage 

WHERE
 SdkMessageProcessingStepId = 'd987ac98-8b85-dd11-b48e-001143ec27a2'

This will produce records if you actually have orphan Plugin Step Images.

Your next step is to remove those records from the database using a SQL command.  Kind of scary, but they are not being used anyway.

Conclusion

I have seen this type of error message a number of times so it does happen occasionally, but not all that frequently.  My theory is that a specific version of the Plugin Registration Tool, probably for CRM 4.0, was responsible for this issue and it was correctly in later versions of the tool.

I think that I need to add this as an upgrade check to my SnapShot! documentation tool.