Tuesday, April 19, 2011

MS CRM 2011 Different services while writting plugin

The input parameter in new Execute() while writing plugin has been changed and is now more useful with more informations.
Few useful services can be created as follows.

public void Execute(IServiceProvider serviceProvider)
{
//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context(the old one in ms crm 4.0) from the service provider. IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

// Obtain the organization service reference. IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

}

No comments:

Post a Comment