register plugin steps programmatically in dynamics crm

 

Every once in a while, we come across a requirement that forces us to register plugins programmatically. This may happen when you want a plugin to be registered to an entity as triggered by another custom code.

In my case, I have a plugin attached to a configuration entity. This plugin in the configuration entity then decides whether to register or unregister another plugin on another entity.

Code

First, I created a class to contain all the parameters we will need.

 

Then, you will need these three methods to retrieve details about the plugin you are going to register. Please adjust these methods to suit your needs.

 

Now, it’s just a matter of using these methods when you’re creating your SdkMessageProcessingStep.

 

Registering a plugin dynamically is as simple as creating a new record of SdkMessageProcessingStep. Just make sure that the assembly of the plugin you are going to register is already in Dynamics CRM.

I hope this helps. Happy CRMing!