Re-Activate Case Plugin


If Case is getting Re-Activated and need to perform some logic. Following is the Code snippet.

It should be registered on both messages i.e. SetState and SetStateDynamicEntity.

IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

if (context.InputParameters.Contains(“EntityMoniker”) && context.InputParameters[“EntityMoniker”] is EntityReference)
{
EntityReference entity = (EntityReference)context.InputParameters[“EntityMoniker”];
if (entity.LogicalName != “incident”)
return;
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

//If the Case is getting Re-Activated
if (context.InputParameters.Contains(“State”) && (context.InputParameters[“State”] as OptionSetValue).Value == 0)
{
//Develop Your Logic Here
}
}

About Kishore Dhanekula

MS Dynamics CRM and .NET Architect
This entry was posted in CRM, Java Script, Ms Dynamics CRM 2013, MS Dynamics CRM 2015. Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s