List of changes in plugin development in CRM 4.0 and CRM 2011


There are not much changes in terms of plugins. there are few changes like instead of using DynamicEntity class we have to use the Entity class. the five major changes are :

1. The IPlugin now resides in Microsoft.Xrm.Sdk namespace instead of Microsoft.Crm.Sdk

public class ClassName : Microsoft.Crm.Sdk.IPlugin
public class ClassName : Microsoft.Xrm.Sdk.IPlugin

2. The Execute method signature of the IPlugin interface has changed, it now expects an IServiceProvider instead of the IPluginExecutionContext.

public void Execute(IPluginExecutionContext context)
public void Execute(IServiceProvider serviceProvider)

3. To get a reference to the IPluginExecutionContext you now need to call the GetService method of the IServiceProvider interface.

public void Execute(IPluginExecutionContext context)
Microsoft.Xrm.Sdk.IPluginExecutionContext context =(Microsoft.Xrm.Sdk.IPluginExecutionContext)
    serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));

4. ICrmService has been changed to IOrganizationService.

ICrmService sdk = context.CreateCrmService(true);
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService sdk = factory.CreateOrganizationService(context.UserId);

5. DynamicEntity has been changed to Entity.

  • Properties property of DynamicEntity no longer exists
  • Getting and Setting values no longer use *Property classes,

eg: no more KeyProperty, StringProperty…etc, simply do int value = (int)entity[“schema_name”];

if (context.InputParameters.Properties.Contains("Target") &&
    context.InputParameters.Properties["Target"] is DynamicEntity)
if (context.InputParameters.Contains("Target") &&
    context.InputParameters["Target"] is Entity)

 

Advertisements

About Dynamics CRM Guru

We are a group of CRM Consultants and have significant experience in transforming businesses in the right way. We use this platform to share our knowledge which might help many others in the digital transformation journey. We are happy to help you if you are looking for any assistance in CRM implementation projects.

Posted on July 27, 2011, in Microsoft CRM 2011, Microsoft Dynamics and tagged . Bookmark the permalink. Leave a comment.

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

%d bloggers like this: