5 syntax changes in Dynamics CRM 2011 plugins
There are number of changes between Dynamics CRM 2011 SDK and CRM 4 SDK. Let’s take a look at what has changed between plugins.
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) | |
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) | |
4. ICrmService has been changed to IOrganizationService. | |
ICrmService sdk = context.CreateCrmService(true); IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); | |
5. DynamicEntity has been changed to Entity. eg: no more KeyProperty, StringProperty…etc, simply do int value = (int)entity[“schema_name”]; | |
if (context.InputParameters.Properties.Contains("Target") && if (context.InputParameters.Contains("Target") && |