Sunday, October 27, 2013

Microsoft Dynamics CRM 2013: Actions: deployment of plugins through CRM Developer Toolkit

I played with new version of CRM Developer Toolkit and was not able to find a way to register plugin that handles action using UI. Following post describes workaround how make it possible.
1. Create Solution and add CRM Plugin project inside:

2. Create new plugin and register it to handle some available action (I used creation of account in post mode):

3. Open class of your plugin and fix line
base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(40, "Create", "account", new Action<LocalPluginContext>(ExecuteHandleCustomAction)));

to line

base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(40, "slick_CustomActionsTest", null, new Action<LocalPluginContext>(ExecuteHandleCustomAction)));

4. Open RegisterFile.crmregister file that is located in your Dynamics CRM 2013 Package project, find line that describes step of your plugin and fix

<Step CustomConfiguration="" Name="HandleCustomAction" Description="Handles Custom Action" Id="00000000-0000-0000-0000-000000000000" 
    MessageName="Create" Mode="Synchronous" PrimaryEntityName="account" Rank="1" SecureConfiguration="" 
    Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">

to line

<Step CustomConfiguration="" Name="HandleCustomAction" Description="Handles Custom Action" Id="00000000-0000-0000-0000-000000000000"
    MessageName="slick_CustomActionsTest" Mode="Synchronous" PrimaryEntityName="none" Rank="1" SecureConfiguration="" 
    Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">

5. Save files and try to deploy your solution to CRM server. In case you’ve done all steps properly you would not get errors during deployment. In case you want to ensure that plugin was deployed properly open Plugin Registration Tool: