Trigger plugin on Action Execution in Dynamics CRM

Hi ,

I am going  to show in the following steps how to trigger plugin on Action execution in CRM


1) Create Action


2) Register plugin


3) Call Action

The following code will show how to call the action using C#

OrganizationRequest callActionRequest = new OrganizationRequest("qdrn_setcustomervip");

callActionRequest["Target"] = new EntityReference("contact", {GUID});

OrganizationResponse callActionResponse = service.Execute(callActionRequest);

Get a Reference to an Instance of Organization Service Inside Plugins

public void Execute(IServiceProvider serviceProvider)

// Obtain the execution context from the service provider.

IPluginExecutionContext context = (IPluginExecutionContext)

// Obtain the organization service reference.

IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);