Tuesday, 27 February 2018

Resolve and Cancel Cases in CRM/Dynamics 365 CE using C#


I was working on Service Module and had to develop a tool which can Resolve and Cancel cases.

Here is the C# code for the same.

To Resolve the Cases
        Entity IncidentResolution = new Entity("incidentresolution");
        IncidentResolution.Attributes["subject"] = "Subject Closed";
        IncidentResolution.Attributes["incidentid"] = new EntityReference("incident", guidCase);
        // Create the request to close the incident, and set its resolution to the
        // resolution created above
        CloseIncidentRequest closeRequest = new CloseIncidentRequest();
        closeRequest.IncidentResolution = IncidentResolution;
        // Set the requested new status for the closed Incident
        closeRequest.Status = new OptionSetValue(5);
        // Execute the close request
        CloseIncidentResponse closeResponse = (CloseIncidentResponse)iService.Execute(closeRequest);

To Cancel the Cases
       SetStateRequest request = new SetStateRequest();
       request.EntityMoniker = new EntityReference("incident", new Guid(strGuids[intGuid]));
       request.State = new OptionSetValue(2);
       request.Status = new OptionSetValue(6);
       SetStateResponse objResponse = (SetStateResponse)iService.Execute(request);

Hope this helps.

Happy CRM'ing


  1. Very informative post. I really do hope for this stuff works! Great article. Keep it up. - Appointment Setting Companies


  2. Very informative post Customer Relationship Management (CRM) Solution Software helps the Decision makers to manage the business with a click of their mouse's button.

  3. CRM NEDİR ?
    CRM, bilgi teknolojileri odaklı bir kavram olarak görünmesine rağmen, CRM aslında yeni bir yönetim felsefesi ve kurumsal bir anlayıştır. Müşteri odaklı satış ve pazarlamanın ardından müşteri memnuniyetini maksimum seviyede tutmak anlayışının hâkim olduğu bu yönetim felsefesinde, uzun süreli müşteri ilişkileri ve müşteri sadakati hedeflenmektedir.

  4. Thanx, this is very Informational Post to Read now I am Waiting for your next post. Dynamics 365 Consultants in US

  5. I Found your article very interesting I learned lot from your content So kind of you to provide us a knowledge of these important things really heplful, Thank you for sharing this vital information and tactics with us.

  6. Hello there. I discovered your web site by way of Google while looking for a similar matter, your website came up. It appears good. I’ve bookmarked it in my google bookmarks to visit then.
    crm consulting firms