I have to reopen a case ( incident ) through my code and then update a field and again close it as resolved.
I am able to open it using SetStateRequest and close it using CloseIncidentRequest. But in between I am not able to use service.Update(caseRecord) to update it. I get the error "This message cannot be used to Close the incident. Use CloseIncidentRequest to close the case". What should I do to update the record ?
SetStateRequest state = new SetStateRequest();
state.State = new OptionSetValue(0); // set the case status to Active
state.Status = new OptionSetValue(1); // set the case status reason to "In Progress"
state.EntityMoniker = record.ToEntityReference();
SetStateResponse stateSet = (SetStateResponse)service.Execute(state);
record["merc_originalowner"] = new EntityReference("systemuser", currentOwner.Id);
record["statuscode"]= new OptionSetValue(1);
service.Update(record); // this line gives error
Entity incidentResolution = new Entity("incidentresolution");
incidentResolution["subject"] = "Resolved";
incidentResolution["incidentid"] = new EntityReference ("incident",record.Id);
CloseIncidentRequest closeRequest = new CloseIncidentRequest();
closeRequest.IncidentResolution = incidentResolution;
*This post is locked for comments