【问题标题】:Use Microsoft Dynamics CRM web service to get customized option set values使用 Microsoft Dynamics CRM Web 服务获取自定义选项集值
【发布时间】:2015-10-29 10:28:17
【问题描述】:

CRM 有一些自定义选项集,例如,Salutation 选项集是为联系人实体定义的。创建或更新联系人时,我需要获取此选项集的值。我尝试使用RetrieveOptionSet 请求获取选项集值如下:

使用http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute的SOAP操作

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>

this page 中的示例代码为我提供了有用的信息。

【问题讨论】:

    标签: soap dynamics-crm-2011


    【解决方案1】:

    您需要使用 RetrieveAttributeRequest,而不是 RetrieveOptionSetRequest。

    非全局(本地)选项集的元数据被定义为实体本身属性的一部分,而不是完全不同的结构。 IE。如果从实体中删除本地选项集属性,则会丢失所有整个选项集定义。但如果它是一个全局选项集,删除实体上的属性引用不会导致选项集的任何数据丢失

    【讨论】:

    • 我们可以使用这个JS方法来访问一些外部数据吗,基本上我们需要动态添加选项集(在CRM系统的选项集值中不存在)。类似于 DependentOptionSet JS 中所做的事情,我们从其他来源获取 XML?
    • @AshishJain 所以基本上你想假装 OptionSet 中有值,但实际上不在 OptionSet 中?
    • 基本上我的详细查询在stackoverflow.com/questions/20658554/…如果有帮助的话。
    【解决方案2】:

    我认为您的问题在几个月前已在此链接中得到解答:

    Dynamics CRM - Accessing Custom Product Option Value

    如果不一样请告诉我,我们会尝试另一种方法;)

    但是再次考虑您的要求,如果我理解正确,该选项集多久会更改一次?为什么不直接使用 SDK 中的 crmsvcutil.exe 检索选项集?

    干杯,

    马里奥

    【讨论】:

    • 由于操作直接在 SOAP 中工作,我会假设他正在使用 javascript 或除 .NET 之外的其他东西,这就是您链接上的答案。
    • 我只是不想让任何人关闭它,因为问题是如此相似。 + 1 用于查找链接...
    • 我正在使用 Java 来检索这些选项。
    猜你喜欢
    • 1970-01-01
    • 2013-04-23
    • 1970-01-01
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-23
    • 1970-01-01
    相关资源
    最近更新 更多