Wednesday 9 November 2011

Step by Step for CRM 2011 plugin

1. Create a class library project,
     Make sure the Target framework is set to ".Net Framework 4"

 2. Sign the assembly by going to project properties and selecting Signing tab, and selecting check box "Sign the assembly", select new and enter name.

 3. Add following references
        microsoft.crm.sdk.proxy
        microsoft.xrm.sdk

4. Add the following namespace to plugin class
using Microsoft.Xrm.Sdk

5. Implement IPlugin interface so it look like e.g

   public class MyPlugin :IPlugin
   {
      public void Execute(IServiceProvider serviceProvider)
     {

      }
    }

6. Build the project and copy and paste the plugin dll and pdb file to

C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly

7. Open Plugin registration tool, Click on register assembly and select the assembly from the above mentioned location
   Select location as Disk

8.Register new step by selecting the assembly in the plugin registration
  Message: Update
  Primary Entity:contact
Secondary Entity:none
Eventing Pipeline Stage of Execution: Pre-operation (CRM 2011 Only)
Execution Mode: Synchronous
Deployment: Server

9.   In the visual studion, go to process and select attach to process, and select the w3wp process, and add the break point with in execute method.

10. update a contact record. The code break point will hit to debug.

Registering PreImage in plugin

Select Organisation in Plugin registeration tool, and select step and then select register Image,

Entity ent= (Entity)context.PreEntityImages["incident"];
                if (ent.Attributes.Contains("attributename"))
                {
                    string attrValue = (string)ent.Attributes["attributename"];                 
                }



http://crmconsultancy.wordpress.com/2010/10/25/plugins-in-crm-2011/
    

No comments:

Post a Comment