Absolutely, it's not all but the point is that check if the message is "close" and then throw an exception right away, but this never happens:
public void Execute(IServiceProvider serviceProvider)
{
try
{
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(context.UserId);
// FOR DEBUGGING PURPOSES
if(context.MessageName == "Close") {
throw new InvalidPluginExecutionException("MessageName == Close");
}
if (context.MessageName == "Close" && context.InputParameters["IncidentResolution"] != null)
{
var caseResolution = (Entity)context.InputParameters["Target"];
var caseEntity = service.Retrieve("incident",
((EntityReference)caseResolution.Attributes["incidentid"]).Id,
new ColumnSet("stq_solutiondescription", "stq_sendclosecaseemailtocustomer", "parentcaseid", "customerid", "stq_resolvechildcases", "stq_resolverelatedcases_noemail", "ownerid", "statecode", "statuscode"));
var status = caseEntity.Attributes.Contains("statuscode") ? (OptionSetValue)caseEntity["statuscode"] : new OptionSetValue(2);
if (CaseIsValidForUpdate(caseEntity, service))
ResolveValidChildCases(caseEntity, caseResolution, service, status);
}
}
catch (Exception e)
{
throw new InvalidPluginExecutionException("ResolveChildCases: " + e.Message + "\r\nStacktrace: " + e.StackTrace);
}
}