CRM 2013: C# code to mark a case as complete RRS feed

  • Question

  • I am looking for the C# code to mark an activity as complete

    Status = complete

    Status Reason  = Resolved (100000004) and the other affects of closing an activity

    The following is not working

    entity_helpdesk["statecode"] = newOptionSetValue(1);


    entity_helpdesk["statuscode"] = new  OptionSetValue(100000004);


    Hasibur Rahman

    Friday, May 8, 2015 10:12 PM


  • Hi,

    for CRM 2013 you can't do a simple update of the statecode and statuscode field.

    If you need to close a Case (incident entity) you need to use a CloseIncidentRequest:

    var incidentResolution = new IncidentResolution
       Subject = "Resolved Sample Incident",
       IncidentId = new EntityReference("incident", _incidentId)
    // Close the incident with the resolution.
    var closeIncidentRequest = new CloseIncidentRequest
       IncidentResolution = incidentResolution,
       Status = new OptionSetValue((int)incident_statuscode.ProblemSolved)

    if you need to close an activity you need to use a SetStateRequest:

    var setStateReq = new SetStateRequest
    EntityMoniker = new EntityReference(entityLogicalName, entityId),
    State = new OptionSetValue(1),
    Status = new OptionSetValue(100000004)

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Saturday, May 9, 2015 4:58 AM