Quantcast
Viewing all articles
Browse latest Browse all 10

Creating a simple Microsoft CRM 4.0 plugin.

The beginning

Ok, in the beginning there was nothing. So, let’s start by taking a look at Introduction to Plug-in Development for Microsoft Dynamics CRM 4.0.

From here we can copy paste some sample code into a new class library.

using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

namespace MyPlugins
{
   public class HelloWorldPlugin: IPlugin
   {
      public void Execute(IPluginExecutionContext context)
      {
         // Call the Microsoft Dynamics CRM Web services here or perform
         // some other useful work.
         throw new InvalidPluginExecutionException("Hello world!");
      }
   }
}

 As you notice when you paste the above code, you’ll get missing an assembly reference errors.

If you haven’t already installed the Microsoft Dynamics CRM 4.0 Sdk , please do so now.

Next add the references and your almost good to go. We can build the code (that doesn’t do anything for now, but what the hay)

How do we get the assembly in CRM ???

There are a few steps you’ll need to preform:

  • Make sure the user with which you want to register the plugin in CRM has the proper roles: either the System Administrator role or the System Customizer role are needed.
  • Make sure the user is a Deployment Administrator in the Deployment Manager.
  • Download the Plugin Registration tool.
  • Run the tool on the server of on a location from where you can connect through AD authentication type (active directory) because otherwise it wont work.

Now you should see the Plugin registration tool.

Enter your connection information in the fields below. In Discovery server you can just type your servername. You’ll be prompted for a password when you hit the Connect button. Once you entered your password, you should see one or more CRM instances in the tree. Hit the organisation you want to register the plugin in and click on the connect button.

The tool is now gathering some information about already registered plugins, messages, …

Click on the register button and select the Register new assembly.

Now press the ellips button (…) to browse to your assembly and choose the location you want the assembly to be stored.

I recommend you use the Database as your assembly storage. The reason for this recommendation is quite simple: if you choose another method you’ll manually have to deploy your assembly after adding or updating.

Next select the register selected plugin’s button. You should now see our newly registered assembly in the list. If you click on the + sign in the registered Plugins & … tree you’ll see the HelloWorld plugin. Right click that and select register new step.

We are now createing a ‘trigger’, so that our plugin code gets hit when something happens. Let’s choose after the update of a contact to start. So make the screen look like this:

Image may be NSFW.
Clik here to view.
Plugin Registration Step

When you now try to edit a contact and save it in crm you’ll see an exception that says something like Hello World Image may be NSFW.
Clik here to view.
:-)

Catch y’all on the flipside


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 10

Trending Articles