Create plug-in for message with no primary entity associated using Dynamics CRM 2011 developer toolkit

Dynamics CRM 2011 developer toolkit is a visual studio extension included in SDK which accelerate creation and deployment of plug-ins, custom workflow assemblies, XAML workflows and Web resources. For more information about Dynamics CRM 2011 developer toolkit: Developer Toolkit for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online.

When create plug-in using developer toolkit, you need to first select the primary entity for the message. There are 19 messages with no primary entity associated, which are listed below.

Associate
Disassociate
Execute
Export
ExportAll
ExportCompressed
ExportCompressedAll
Import
ImportAll
ImportCompressedAll
ImportCompressedWithProgress
ImportWithProgress
Publish
PublishAll
RemoveProductFromKit
RetrievePersonalWall
RetrieveRecordWall
UnlockInvoicePricing
UnlockSalesOrderPricing

To create plug-in using developer toolkit for message with no primary entity associated, you can create a plug-in as normal process and modify the generated .cs code file and the RegisterFile.crmregister file.

1. select any entity and create plug-in in CRM Explorer

2. select any message to use, and configure other setting as you need for the message have no primary entity.

3. modify generated .cs code file, so that the plug-in will be executed

the line number is likely to be line 31, on the top of the generated plug-in .cs code file within the plug-in constructor.

update the message to the one have no primary entity and change the entity name to empty string

base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(10, "Associate", "", new Action<LocalPluginContext>(ExecutePreValidatePostcodeAssociate)));

4. modify RegisterFile.crmregister file, so that the plug-in can be deployed to the CRM server correctly

find the xml for previously generated plug-in, update the message and change entity name to empty string

<Step CustomConfiguration="" Name="PreValidatePostcodeAssociate" Description="Pre-Validation of Postcode Associate" Id="881876af-8ba0-e111-b344-00155d4c5b01" MessageName="Associate" Mode="Synchronous" PrimaryEntityName="" Rank="1" SecureConfiguration="" Stage="PreOutsideTransaction" SupportedDeployment="Both"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s