Quantcast
Channel: Dynamics 365 Customer Engagement
Viewing all articles
Browse latest Browse all 286

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

$
0
0
Hi,

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 = newEntity("incidentresolution");
        IncidentResolution.Attributes["subject"] = "Subject Closed";
        IncidentResolution.Attributes["incidentid"] = newEntityReference("incident", guidCase);
        // Create the request to close the incident, and set its resolution to the
        // resolution created above
        CloseIncidentRequest closeRequest = newCloseIncidentRequest();
        closeRequest.IncidentResolution = IncidentResolution;
        // Set the requested new status for the closed Incident
        closeRequest.Status = newOptionSetValue(5);
        // Execute the close request
        CloseIncidentResponse closeResponse = (CloseIncidentResponse)iService.Execute(closeRequest);

To Cancel the Cases
       SetStateRequest request = newSetStateRequest();
       request.EntityMoniker = newEntityReference("incident", newGuid(strGuids[intGuid]));
       request.State = newOptionSetValue(2);
       request.Status = newOptionSetValue(6);
       SetStateResponseobjResponse = (SetStateResponse)iService.Execute(request);

Hope this helps.

--
Happy CRM'ing
Gopinath

Viewing all articles
Browse latest Browse all 286

Trending Articles