Friday, September 4, 2009

Resolve case programmatically

You have to create incidentresolution entity object and also then execute a CloseIncidentRequest, sample code looks like this:

incidentresolution objJobResolution = new incidentresolution();
objJobResolution.incidentid = new Lookup();
objJobResolution.incidentid.type = "incident";
objJobResolution.incidentid.Value = ; // Job id
objJobResolution.subject = "subject";

try
{
objCrmService.Create(objJobResolution);

CloseIncidentRequest closeJob = new CloseIncidentRequest();
closeJob.IncidentResolution = objJobResolution;
closeJob.Status = 5;

CloseIncidentResponse resp = (CloseIncidentResponse)objCrmService.Execute(closeJob);

}
catch (System.Web.Services.Protocols.SoapException soapEx)
{
continue;
}