【问题标题】:How to cancel a case (incident) in MS CRM via webservice如何通过 Web 服务取消 MS CRM 中的案例(事件)
【发布时间】:2010-09-13 12:55:26
【问题描述】:

问题:如何使用 WebService 在 Microsoft CRM 4 中取消案例(事件)?

我写这篇文章是因为我花了很长时间才找到正确的答案,而且 MS 的文档在这方面没有太大帮助,希望这可以为其他人节省时间。

【问题讨论】:

    标签: dynamics-crm dynamics-crm-4


    【解决方案1】:

    答案(在 VB.NET 中):

     Dim CancelRequest As New SetStateIncidentRequest
        CancelRequest.IncidentState = IncidentState.Canceled
        CancelRequest.IncidentStatus = -1
        CancelRequest.EntityId = // [GUID OF INCIDENT]
    
        Dim CancelResponse As New SetStateIncidentResponse
    
        Try
    
            CancelResponse = objCrm.Execute(CancelRequest)
    
        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
    
        Catch ex As Exception
    
            strErrors = strErrors & vbCrLf & vbCrLf & ex.Message
    
            Return False
    
        End Try
    
        Return True
    

    其中 objCRM 是 CrmService 的一个实例。

    【讨论】:

      【解决方案2】:

      这里是 CRM2011 的 C# 版本。

       try
       {
           SetStateRequest stateRequest = new SetStateRequest();
           stateRequest.EntityMoniker = (EntityReference)entity.ToEntityReference();
           stateRequest.State = new OptionSetValue(2); //Code - Cancelled.
           stateRequest.Status = new OptionSetValue(6); // Reason - Cancelled. 
      
           SetStateResponse response = new SetStateResponse();
           response = (SetStateResponse)service.Execute(stateRequest);
       }
       catch (Exception ex)
       {
           // Catch exception & do whatever you want man... :)
       }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多