locked
CloseIncidentRequest returns error RRS feed

  • Question

  • I want to close case programmatically.I used the following code.
                incidentresolution res = new incidentresolution();
                res.incidentid = new Lookup();
                res.incidentid.type = "incident";
                res.incidentid.Value = new Guid("90B850E9-3387-DE11-8F3F-0003FF19DE88");
                res.statecode = new IncidentResolutionStateInfo();
                res.statecode.Value = IncidentResolutionState.Completed;
                res.description = "resolved";
                res.timespent = new CrmNumber();
                res.timespent.Value = 4;
                Guid resid = service.Create(res);
    
                incidentresolution resp = (incidentresolution)service.Retrieve(EntityName.incidentresolution.ToString(), resid, new AllColumns());
    
                CloseIncidentRequest req = new CloseIncidentRequest();
                req.IncidentResolution = resp;
                
                req.Status = 5;
                CloseIncidentResponse closeresp = (CloseIncidentResponse)service.Execute(req);

    But the code returns soap error:A generic SQL error.Is anything wrong in the code.

    Regards

    Raji

     

    Monday, August 31, 2009 9:03 AM

Answers

  • Hi,

    you should not create the incidentresolution as a single entry ( I assume, that the crm tries to create it a second time, which produced your error)

    incidentresolution res = new incidentresolution();
    res.incidentid = new Lookup();
    res.incidentid.type = EntityName.incident.ToString();
    res.incidentid.Value = new Guid("0b94e8e2-1596-de11-b7cc-000c296bb2ca");
    res.description = "resolved";
    res.statecode = new IncidentResolutionStateInfo();
    res.statecode.Value = IncidentResolutionState.Completed;
    res.timespent = new CrmNumber();
    res.timespent.Value = 4;
    
    CloseIncidentRequest req = new CloseIncidentRequest();
    req.IncidentResolution = res;
    req.Status = 5;
    
    CloseIncidentResponse closeresp = (CloseIncidentResponse)service.Execute(req);
    Monday, August 31, 2009 10:11 AM

All replies

  • Hi Raji,

    to change the state of a entity you have to use setstate.
    See SDK for further information
    http://msdn.microsoft.com/en-us/library/bb928212.aspx
    Viele Grüße

    Michael Sulz
    axcentro GmbH
    MVP für Microsoft Dynamics CRM
    Monday, August 31, 2009 9:14 AM
  • THANKS FOR THE REPLY.BUT I WANT TO RESOLVE THE CASE PROGRAMMATICALLY.

    Regards
    Raji
    Monday, August 31, 2009 9:42 AM
  • Hi,

    you should not create the incidentresolution as a single entry ( I assume, that the crm tries to create it a second time, which produced your error)

    incidentresolution res = new incidentresolution();
    res.incidentid = new Lookup();
    res.incidentid.type = EntityName.incident.ToString();
    res.incidentid.Value = new Guid("0b94e8e2-1596-de11-b7cc-000c296bb2ca");
    res.description = "resolved";
    res.statecode = new IncidentResolutionStateInfo();
    res.statecode.Value = IncidentResolutionState.Completed;
    res.timespent = new CrmNumber();
    res.timespent.Value = 4;
    
    CloseIncidentRequest req = new CloseIncidentRequest();
    req.IncidentResolution = res;
    req.Status = 5;
    
    CloseIncidentResponse closeresp = (CloseIncidentResponse)service.Execute(req);
    Monday, August 31, 2009 10:11 AM