Skip to main content

Notifications

Announcements

No record found.

Closing Incident Record

Recently I had this question come up, and wanted to discuss the difference between closing an incident (Case) as resolved, or closing an incident as cancelled. There are a few other options, but we will focus on these two.

The Case entity in CRM, has an associated entity called Case Resolution (incidentresolution). When a case was opened and then completed with a resolution, the closure of the case will be via the Incident Resolution Entity, as shown in the code below. 

IncidentResolution resolution = new IncidentResolution
{
   Subject = "Resolved Sample Incident",
   IncidentId = new EntityReference(Incident.EntityLogicalName, _incidentId)
};

// Close the incident with the resolution.
CloseIncidentRequest request = new CloseIncidentRequest
{
   IncidentResolution = incidentResolution,
   Status = new OptionSetValue((int)incident_statuscode.ProblemSolved)
};

CloseIncidentResponse closeResponse = (CloseIncidentResponse)service.Execute(closeIncidentRequest);

 

However, when an incident as cancelled, there is no resolution, so the closure of the incident happens directly within the Case entity, and there is no need for a closure. See the code below to notice the difference.

SetStateIncidentRequest request = new SetStateIncidentRequest()
{
   IncidentState = new OptionSetValue(2), // Cancelled
   IncidentStatus = new OptionSetValue(6), // Cancelled
   EntityId = new EntityReference("incident", incidentId)
}

Comments

*This post is locked for comments