开发者

Resolving incidents (closing cases) in CRM4 through webservices?

开发者 https://www.devze.com 2022-12-15 04:40 出处:网络
I\'m trying to resolve/close Dynamics CRM4 cases/incidents through webservices. A single SetStateIncidentRequest is not enough and returns a Server was unable to process request error message. I thin

I'm trying to resolve/close Dynamics CRM4 cases/incidents through webservices.

A single SetStateIncidentRequest is not enough and returns a Server was unable to process request error message. I think it has something to do with active workflows that trigger on case's attribute changes. I don't know if there's anything else preventing the request to work.

Since it is possible to close those cases through the GUI, I g开发者_StackOverflow社区uess there's a "correct" set of steps to follow in order to achieve it through CrmService; unfortunately, I've been googleing it for a while without finding what I want. Could anybody help me, please?


To resolve a case in CRM (in VB.NET), I do the following:

Try

Dim activity As New incidentresolution
Dim closeRequest As New CloseIncidentRequest
Dim closeResponse As New CloseIncidentResponse
Dim strErrors As String = String.Empty()

activity.incidentid = New Lookup
activity.incidentid.type = EntityName.incident.ToString
activity.incidentid.Value = //[GUID OF INCIDENT]

activity.ownerid = New Owner
activity.ownerid.type = EntityName.systemuser.ToString
activity.ownerid.Value = //[GUID OF USER PERFORMING ACTION]

activity.statecode = New IncidentResolutionStateInfo
activity.statecode.Value = 1 //Resolved

activity.statuscode = New Status
activity.statuscode.Value = 5 //Problem Solved

closeRequest.IncidentResolution = activity
closeRequest.Status = 5 //Problem Solved

// IF REQUIRED:
activity.timespent = New CrmNumber
activity.timespent.Value = //[INTEGER REPRESENTING No. OF MIN SPENT ON CASE]

closeResponse = objCrm.Execute(closeRequest)

Catch ex As System.Web.Services.Protocols.SoapException

    Dim root As XmlElement = ex.Detail
    strErrors = strErrors & vbCrLf & vbCrLf & root.ChildNodes(0).ChildNodes(3).InnerText

    Return False

End Try


Here's a tip - catch the SoapException and examine the Detail.OuterXML property and you will get a more detailed error message. It's possible you're not building your request correctly.


Indeed, I didn't know that there exists a CloseIncidentRequest class to use with the CrmService.Execute() method. Most probably the SetStateIncidentRequeset won't work because it's expected that incident resolutions are created that way. Pity that names for classes and actions aren't used consistently (case/incident, resolution/closing)...

0

精彩评论

暂无评论...
验证码 换一张
取 消