状态码和状态码不匹配,即使两者都已显式设置 [英] statuscode and statecode mismatch even though both are explicitly set

查看:64
本文介绍了状态码和状态码不匹配,即使两者都已显式设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过SOAP Web服务创建服务约会实体时出现错误,提示状态码和状态码不匹配:

I'm getting an error when creating a service appointment entity through the SOAP webservice about a mismatch between statuscode and statecode:


4不是状态代码
ServiceAppointmentState的有效状态代码。请在serviceappointment上打开。

4 is not a valid status code for state code ServiceAppointmentState.Open on serviceappointment.

本质上说保留(状态码4)不是打开状态(状态码1)。的确如此,它实际上是计划状态的成员(状态代码3),但是在我的请求中,我正确地将状态代码设置为3!

Essentially saying that reserved (statuscode 4) isn't a member of the Open state (statecode 1). Which is true, it's actually a member of the Scheduled state (statecode 3) but in my request I'm correctly setting statecode to 3!

有人知道为什么我将服务预约设置为计划状态的原因吗?

Does anyone know why my setting the serviceappointment to the Scheduled state is being ignored?

完整请求:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
         <entity xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
            <a:Attributes xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
               <a:KeyValuePairOfstringanyType>
                  <b:key>statecode</b:key>
                  <b:value i:type="a:OptionSetValue">
                     <a:Value>3</a:Value>
                  </b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>serviceid</b:key>
                  <b:value i:type="a:EntityReference">
                     <a:Id>c5b8179c-3cab-e211-ab0a-00155d1438e9</a:Id>
                     <a:LogicalName>service</a:LogicalName>
                     <a:Name i:nil="true" />
                  </b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>scheduledend</b:key>
                  <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:dateTime">2013-06-13T14:30:00</b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>statuscode</b:key>
                  <b:value i:type="a:OptionSetValue">
                     <a:Value>4</a:Value>
                  </b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>subject</b:key>
                  <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:string">Support handover</b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>scheduledstart</b:key>
                  <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:dateTime">2013-06-13T09:00:00</b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>py3_workpackageid</b:key>
                  <b:value i:type="a:EntityReference">
                     <a:Id>dc7008cf-2eab-e211-ab0a-00155d1438e9</a:Id>
                     <a:LogicalName>py3_workpackage</a:LogicalName>
                     <a:Name i:nil="true" />
                  </b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>customers</b:key>
                  <b:value i:type="a:EntityCollection">
                     <a:Entities>
                        <a:Entity>
                           <a:Attributes>
                              <a:KeyValuePairOfstringanyType>
                                 <b:key>partyid</b:key>
                                 <b:value i:type="a:EntityReference">
                                    <a:Id>050d25a8-03c9-e211-866e-00155d143602</a:Id>
                                    <a:LogicalName>account</a:LogicalName>
                                    <a:Name i:nil="true" />
                                 </b:value>
                              </a:KeyValuePairOfstringanyType>
                           </a:Attributes>
                           <a:EntityState i:nil="true" />
                           <a:FormattedValues />
                           <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
                           <a:LogicalName>activityparty</a:LogicalName>
                           <a:RelatedEntities />
                        </a:Entity>
                     </a:Entities>
                     <a:EntityName i:nil="true" />
                     <a:MinActiveRowVersion i:nil="true" />
                     <a:MoreRecords>false</a:MoreRecords>
                     <a:PagingCookie i:nil="true" />
                     <a:TotalRecordCount>0</a:TotalRecordCount>
                     <a:TotalRecordCountLimitExceeded>false</a:TotalRecordCountLimitExceeded>
                  </b:value>
               </a:KeyValuePairOfstringanyType>
               <a:KeyValuePairOfstringanyType>
                  <b:key>resources</b:key>
                  <b:value i:type="a:EntityCollection">
                     <a:Entities>
                        <a:Entity>
                           <a:Attributes>
                              <a:KeyValuePairOfstringanyType>
                                 <b:key>partyid</b:key>
                                 <b:value i:type="a:EntityReference">
                                    <a:Id>3e17fce0-e9cd-e211-866e-00155d143602</a:Id>
                                    <a:LogicalName>systemuser</a:LogicalName>
                                    <a:Name i:nil="true" />
                                 </b:value>
                              </a:KeyValuePairOfstringanyType>
                           </a:Attributes>
                           <a:EntityState i:nil="true" />
                           <a:FormattedValues />
                           <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
                           <a:LogicalName>activityparty</a:LogicalName>
                           <a:RelatedEntities />
                        </a:Entity>
                     </a:Entities>
                     <a:EntityName i:nil="true" />
                     <a:MinActiveRowVersion i:nil="true" />
                     <a:MoreRecords>false</a:MoreRecords>
                     <a:PagingCookie i:nil="true" />
                     <a:TotalRecordCount>0</a:TotalRecordCount>
                     <a:TotalRecordCountLimitExceeded>false</a:TotalRecordCountLimitExceeded>
                  </b:value>
               </a:KeyValuePairOfstringanyType>
            </a:Attributes>
            <a:EntityState i:nil="true" />
            <a:FormattedValues xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
            <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
            <a:LogicalName>serviceappointment</a:LogicalName>
            <a:RelatedEntities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
         </entity>
      </Create>
   </soap:Body>
</soap:Envelope>

从组织中删除解决方案时,偶尔会出现相同的错误,因此我在研究问题。我所发现的只是此论坛帖子 ,但似乎无法解决。

it appears the same error occasionally happens when deleting solutions from an organisation so I've had trouble researching the issue. All I've found is this forum post, but it doesn't seem to be resolved.

推荐答案

状态码是只读属性,创建新记录时不能设置其值。

statecode is a readonly property, you can't set its value when you create a new record.

要设置正确的值,您需要始终使用 SetStateRequest

To set the right value you need to use always a SetStateRequest

http://msdn.microsoft.com/zh-CN/library/microsoft.crm.sdk.messages.setstaterequest.aspx

结论:首先需要创建记录(它将处于打开状态),然后将其状态更改为保留。

Conclusion: first you need to create the record (and it will be in open state) and after change its status to reserved.

这篇关于状态码和状态码不匹配,即使两者都已显式设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆