CRM 有一些自定义选项集,例如,Salutation 选项集是为联系人实体定义的。创建或更新联系人时,我需要获取此选项集的值。我尝试使用RetrieveOptionSetrequest 来获取选项集值,如下所示:
要使用的 SOAP 操作http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute
SOAP 请求正文
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <request i:type="a:RetrieveOptionSetRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
               <a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                  <a:KeyValuePairOfstringanyType>
                      <b:key>MetadataId</b:key>
                      <b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</b:value>
                  </a:KeyValuePairOfstringanyType>
                  <a:KeyValuePairOfstringanyType>
                      <b:key>RetrieveAsIfPublished</b:key>
                      <b:value i:type="c:boolean" xmlns:c="http://www.w3.org/2001/XMLSchema">true</b:value>
                  </a:KeyValuePairOfstringanyType>
                  <a:KeyValuePairOfstringanyType>
                      <b:key>Name</b:key>
                      <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">my_type</b:value>
                  </a:KeyValuePairOfstringanyType>
               </a:Parameters>
               <a:RequestId i:nil="true" />
               <a:RequestName>RetrieveOptionSet</a:RequestName>
            </request>
        </Execute>
    </s:Body>
</s:Envelope>
问题是我只能使用这个请求来获取全局选项集,但是对于自定义选项集,这个请求只返回一个未找到的错误。
有谁知道如何获得自定义选项集值?
编辑:我正在使用 Java 客户端访问 Dynamics CRM Web 服务。这是我用来成功获取选项集值的最终 SOAP 请求正文。
<s:Envelope>
  <s:Body>
    <Execute>
      <request i:type="a:RetrieveAttributeRequest">
        <a:Parameters>
          <a:KeyValuePairOfstringanyType>
            <b:key>MetadataId</b:key>
            <b:value i:type="c:guid">00000000-0000-0000-0000-000000000000</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>RetrieveAsIfPublished</b:key>
            <b:value i:type="c:boolean">true</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>EntityLogicalName</b:key>
            <b:value i:type="c:string">contact</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>LogicalName</b:key>
            <b:value i:type="c:string">my_type</b:value>
          </a:KeyValuePairOfstringanyType>
        </a:Parameters>
        <a:RequestId i:nil="true"/>
        <a:RequestName>RetrieveAttribute</a:RequestName>
      </request>
    </Execute>
  </s:Body>
</s:Envelope>
此页面中的示例代码为我提供了有用的信息。