Announcements
Good Day
We have a requirement from Customer Experience, why a Case is ReActivated. They are asking for a drop down optionset and it should apprear only once a case is Re-Activated.
I tried Nishant Rana Blog, which creates a plugin and it is supposed to be activated once a Case is Re-Open/Re-Acticated.
Nishant Rana Code is not working for me, It is even running when a case status is Changed(New->In Progress).
My plugin Code below:
if (context.InputParameters.Contains("EntityMoniker"))
{
var targetEntity = (EntityReference)context.InputParameters["EntityMoniker"];
if (targetEntity.LogicalName == "incident")
{
Entity incident = new Entity("incident");
incident.Id = context.PrimaryEntityId;
QueryExpression query = new QueryExpression("incident");
query.ColumnSet = new ColumnSet("col1", "reopenflag");
query.Criteria.Conditions.Add(new ConditionExpression("incidentid", ConditionOperator.Equal, incident.Id));
var result = service.RetrieveMultiple(query);
foreach (var entity in result.Entities)
{
// Get the Columns from the Entity Obj Like this. Depands on type of the Column.
_valueDate = entity.Contains("field1") && entity["field1"] != null ? entity["field1"]).Value : DateTime.MinValue;
}
int state = ((OptionSetValue)context.InputParameters["State"]).Value;
if (state==0)
{
incident.Attributes["flag"] = true;
incident.Attributes["field1"] = GetValidLocalDate(DateTime.Now);
incident.Attributes["pluginmessage"] = Convert.ToString(context.MessageName);
service.Update(incident);
}
}
}
Hi,
You should check Case previous status. And if pervious status is Resolved or Cancelled then only you should execute your code.
Two thing you will have to check in your plugin -- Case previous status and Case status value which is coming in Context.
When you check previous status and when case status is changed from New-->Inprogress your code will not get executed as previous status is not resolved or cancelled instead it is new.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156