To close incident record we need to update statecode, for this generally we do use SetStateRequest but this will works only for cancel the case or incident not for close or resolve. Below is the code snippet to close an incident.
CloseIncidentRequest closeIncidentRequest = new CloseIncidentRequest();
Entity incidentEntity = new Entity("incidentresolution");
incidentEntity.Attributes.Add("incidentid", new EntityReference("incident", caseId));
closeIncidentRequest.IncidentResolution = incidentEntity;
closeIncidentRequest.Status = new OptionSetValue(statusReason);
CloseIncidentResponse closeIncidentResponse = (CloseIncidentResponse)service.Execute(closeIncidentRequest);
CloseIncidentRequest closeIncidentRequest = new CloseIncidentRequest();
Entity incidentEntity = new Entity("incidentresolution");
incidentEntity.Attributes.Add("incidentid", new EntityReference("incident", caseId));
closeIncidentRequest.IncidentResolution = incidentEntity;
closeIncidentRequest.Status = new OptionSetValue(statusReason);
CloseIncidentResponse closeIncidentResponse = (CloseIncidentResponse)service.Execute(closeIncidentRequest);
No comments:
Post a Comment