web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Problems Resolving a Case/Incident programatically

(0) ShareShare
ReportReport
Posted on by 135

I have the following code which tries to set the StateCode and StatusCode of an Incident in an aspx page which is called when I click on a link in the Case window (link added by modifying ISV.config). 

I am trying to resolve the case and set the statuscode to a value of 9 (a custom statuscode).  I get an error "couldn't process the request".

Any ideas why this code doesn't work?

Thanks,

Aravind Hande

----------------------

Dim myIncident As New incident()myIncident.incidentid = New Key()

myIncident.incidentid.Value = incidentID

'Set state to resolved

myIncident.statecode = New IncidentStateInfo

myIncident.statecode.Value = IncidentState.Resolved

'set status to issue created

myIncident.statuscode = New Status()

myIncident.statuscode.Value = 9 'Issue created

'Create the target object for the request.

Dim target As TargetUpdateIncident = New TargetUpdateIncident()

'Set the properties of the target object.

target.Incident = myIncident

'create the request object.

Dim update As UpdateRequest = New UpdateRequest()

'Set the properties of the request object.

update.Target = target

'Execute the request.

Dim updated As UpdateResponse = DirectCast(crmSrvc.Execute(update), UpdateResponse)

*This post is locked for comments

I have the same question (0)
  • Inogic Profile Picture
    764 on at

    Hi Aravind,

     

    Please use the “SetStateIncidentRequest” to update statecode and statuscode of incident in CRM

     

    For more information of this request please check crm SDK.

     

    HTH

     

  • Aravind Hande Profile Picture
    135 on at

    Thanks.  That was helpful.  So, I replaced that code with the following code: (Incidentstatus 9 is a custom value).  I still get the following error: System.Web.Services.Protocols.SoapException: Server was unable to process request.  Could this have to do with the fact that I am trying to update the incident programatically when a link/button is clicked in a window that is displaying the incident involved?

    Thanks,

    Aravind Hande

    'Set state to resolved and status to "issue created"

    state.IncidentState = IncidentState.Resolved

    state.IncidentStatus = 9 'Issue created

    state.EntityId = incidentID

    'Execute the request.

    Dim stateSet As SetStateIncidentResponse = DirectCast(crmSrvc.Execute(state), SetStateIncidentResponse)

     

  • Inogic Profile Picture
    764 on at

    Hi Aravnd,

    Try this 

      //create object of incidentresolution
                        ocaseresolve = new incidentresolution();

                        //Incidentid
                        //create lookup
                        Lookup luIncidentId = CrmTypes.CreateLookup(EntityName.incidentresolution.ToString(), new Guid(strIncidentId));
                        ocaseresolve.incidentid = luIncidentId;

                        //Resolution Type
                        //create status
                        Status oStatus = CrmTypes.CreateStatus(Convert.ToInt32(strResolutionType));
                        ocaseresolve.statuscode = oStatus;

                        //Resolution
                        ocaseresolve.subject = strResolution;

                        //Description
                        ocaseresolve.description = strDescription;
                        //close incedent request
                        CloseIncidentRequest request = new CloseIncidentRequest();

                        //set incident resolution of req
                        request.IncidentResolution = ocaseresolve;
                        //set status of req
                        request.Status = Convert.ToInt32(strResolutionType); // 5 = Resolved (Problem Solved)

                        //execute request
                        CloseIncidentResponse response = (CloseIncidentResponse)service.Execute(request);

    SetStateIncident can be used to open a resolved case. 

    Hope this helps!

     Sam

     

  • Sudhanshu Sahoo Profile Picture
    270 on at

    This really works.

    I have tried in the setstateentity and also setincidentstate, but nothings worked only exception i got is server was unable to process your request.

     

    Sudhanshu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans