Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM


Leave a comment

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 2013/2015

Steps

1) Create Action

CreateAction

2) Register plugin

RegisterPlugin

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);

Advertisements


Leave a comment

MS CRM 2011 -Get a Refrence to an Instance of Organization Service Inside Plugins

public void Execute(IServiceProvider serviceProvider)
{

// Obtain the execution context 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);

}