首页 文章

使用Silverlight关闭CRM 2011中的事件

提问于
浏览
0

关于Dynamics CRM 2011组织服务的事件,我有一个很大的问题 . 没有CloseIncidentRequest类可用,并且还有fetch xml我没有机会:

public void CloseCase(Guid pCaseId)
    {
        FetchExpression fetch = new FetchExpression();
        String requestMain = "";
        requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
        requestMain += "  <s:Body>";
        requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
        requestMain += "      <request i:type=\"b:CloseIncidentRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
        requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
        requestMain += "          <a:KeyValuePairOfstringanyType>";
        requestMain += "            <c:key>IncidentResolution</c:key>";
        requestMain += "            <c:value i:type=\"a:Entity\">";
        requestMain += "              <a:Attributes>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>incidentid</c:key>";
        requestMain += "                  <c:value i:type=\"a:EntityReference\">";
        requestMain += "                    <a:Id>{0}</a:Id>";
        requestMain += "                    <a:LogicalName>incident</a:LogicalName>";
        requestMain += "                    <a:Name i:nil=\"true\" />";
        requestMain += "                  </c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>subject</c:key>";
        requestMain += "                  <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">Parent Case has been resolved</c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "              </a:Attributes>";
        requestMain += "              <a:EntityState i:nil=\"true\" />";
        requestMain += "              <a:FormattedValues />";
        requestMain += "              <a:Id>{1}</a:Id>";
        requestMain += "              <a:LogicalName>incidentresolution</a:LogicalName>";
        requestMain += "              <a:RelatedEntities />";
        requestMain += "            </c:value>";
        requestMain += "          </a:KeyValuePairOfstringanyType>";
        requestMain += "          <a:KeyValuePairOfstringanyType>";
        requestMain += "            <c:key>Status</c:key>";
        requestMain += "            <c:value i:type=\"a:OptionSetValue\">";
        requestMain += "              <a:Value>5</a:Value>";
        requestMain += "            </c:value>";
        requestMain += "          </a:KeyValuePairOfstringanyType>";
        requestMain += "        </a:Parameters>";
        requestMain += "        <a:RequestId i:nil=\"true\" />";
        requestMain += "        <a:RequestName>CloseIncident</a:RequestName>";
        requestMain += "      </request>";
        requestMain += "    </Execute>";
        requestMain += "  </s:Body>";
        requestMain += "</s:Envelope>";

        fetch.Query = String.Format(requestMain, pCaseId.ToString(), pCaseId.ToString());

        _orgService.BeginRetrieveMultiple(fetch, CloseCaseResult, null);

有什么想法解决这个问题吗?

最好的祝福

1 回答

  • 1

    重新检查以下关于在silverlight中调用IOrganizationService的文章 - http://mileyja.blogspot.com/2011/06/retrieve-entity-in-microsoft-dynamics.html

    代码的第一部分(创建请求)应替换为以下代码:

    Entity incidentresolution = new Entity()
        {
            LogicalName = "incidentresolution"
        };
        incidentresolution["subject"] = "Incident was closed";
        incidentresolution["incidentid"] = new EntityReference()
        {
            Id = Guid.Empty,
            LogicalName = "incident"
        };
    
        OrganizationRequest request = new OrganizationRequest()
        {
            RequestName = "CloseIncident"
        };
    
        request["incidentresolution"] = incidentresolution;
        request["status"] = new OptionSetValue()
        {
            Value = -1
        };
    

    当然,您应该将Guid.Empty替换为您要关闭的事件ID .

相关问题