通过Web服务解决CRM4中的事件(结案)?

时间:2009-12-29 14:33:48

标签: web-services dynamics-crm dynamics-crm-4

我正在尝试通过网络服务解决/关闭Dynamics CRM4案例/事件。

单个SetStateIncidentRequest是不够的,并返回Server was unable to process request错误消息。我认为这与触发案例属性更改的活动工作流程有关。我不知道是否还有其他因素阻止了请求的运行。

由于可以通过GUI关闭这些情况,我想有一套“正确”的步骤要通过CrmService来实现;不幸的是,我一直在谷歌一段时间而没有找到我想要的东西。请问有人帮帮我吗?

3 个答案:

答案 0 :(得分:1)

要解决CRM中的案例(在VB.NET中),我会执行以下操作:

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

答案 1 :(得分:0)

这是一个提示 - 捕获SoapException并检查Detail.OuterXML属性,您将收到更详细的错误消息。您可能无法正确构建请求。

答案 2 :(得分:0)

实际上,我不知道有CloseIncidentRequest类可以与CrmService.Execute()方法一起使用。最有可能SetStateIncidentRequeset不起作用,因为预计会以这种方式创建事件解决方案。遗憾的是,类和行为的名称并未一致使用(案例/事件,解决/结束)......