【问题标题】:FetchXML View to Include Attributes from Nested Link-EntityFetchXML 视图以包含来自嵌套链接实体的属性
【发布时间】:2013-12-01 07:13:09
【问题描述】:

我想要一个显示 3 个实体的属性的视图:
统计信息具有对帐户的查找,而帐户具有对地址的查找。

该视图是关于统计的,我想要所有 3 个实体的属性;这甚至可能吗?

问题出在 GridXML。
我想在 GridXML 中包含 wl_city 属性。

这是带有链接实体的 FetchXML:

<fetchxml>
  <fetch version="1.0" output-format="xml-platform" mapping="logical">
    <entity name="sb_statistics">
      <order attribute="sb_amount" descending="false" />
      <!-- It is easy to get these into the GridXML -->
      <attribute name="sb_debtor" />
      <attribute name="sb_date" />
      <attribute name="sb_amount" />
      <link-entity name="account" from="accountid" to="sb_debtor" 
       alias="relatedAccount" link-type="outer">
        <!-- It is possible to get this into the GridXML
             by using the link-entity alias: relatedAccount.wl_towncity -->
        <attribute name="wl_towncity" />
        <link-entity name="wl_postalcode" from="wl_postalcodeid" 
          to="wl_postaltowncity" alias="relatedAddress" link-type="outer">
          <!-- I have trouble getting this attribute into the GridXML -->
          <attribute name="wl_city" />
        </link-entity>
      </link-entity>
      <attribute name="sb_statisticsid" />
    </entity>
  </fetch>
</fetchxml>

当我如下更改 GridXML 时,打开视图时会显示此错误:
"要使用此保存的查询,您必须删除引用已删除或不可搜索项的条件和列"

  <layoutxml>
    <grid name="resultset" object="10008" jump="sb_name" select="1" preview="1" 
     icon="1">
      <row name="result" id="sb_statisticsid" multiobjectidfield="1">
        <cell name="sb_amount" width="100" />
        <cell name="sb_date" width="100" />
        <cell name="sb_debtor" width="100" />
        <cell name="relatedAccount.relatedAddress.wl_city" width="100" />
      </row>
    </grid>
  </layoutxml>

以下 GridXML 在打开视图时显示此错误:
意外错误发生错误”。

  <layoutxml>
    <grid name="resultset" object="10008" jump="sb_name" select="1" preview="1" 
     icon="1">
      <row name="result" id="sb_statisticsid" multiobjectidfield="1">
        <cell name="sb_amount" width="100" />
        <cell name="sb_date" width="100" />
        <cell name="sb_debtor" width="100" />
        <cell name="relatedAddress.wl_city" width="100" />
      </row>
    </grid>
  </layoutxml>

下面的 GridXML 导致在打开视图时显示此错误:
“要使用此保存的视图,您必须删除引用已删除或不可搜索列的条件和列”。

  <layoutxml>
    <grid name="resultset" object="10008" jump="sb_name" select="1" preview="1" 
     icon="1">
      <row name="result" id="sb_statisticsid" multiobjectidfield="1">
        <cell name="sb_amount" width="100" />
        <cell name="sb_date" width="100" />
        <cell name="sb_debtor" width="100" />
        <cell name="wl_city" width="100" />
      </row>
    </grid>
  </layoutxml>

这个保存的查询有效,但它只包含来自主实体和第一个链接实体的属性。

<savedquery>
  <IsCustomizable>1</IsCustomizable>
  <CanBeDeleted>0</CanBeDeleted>
  <isquickfindquery>0</isquickfindquery>
  <isprivate>0</isprivate>
  <isdefault>0</isdefault>
  <returnedtypecode>10008</returnedtypecode>
  <savedqueryid>{df101ac4-2e4d-e311-9377-005056bd0001}</savedqueryid>
  <layoutxml>
    <grid name="resultset" object="10008" jump="sb_name" select="1" preview="1" 
     icon="1">
      <row name="result" id="sb_statisticsid" multiobjectidfield="1">
        <cell name="sb_amount" width="100" />
        <cell name="sb_date" width="100" />
        <cell name="sb_debtor" width="100" />  
        <cell name="relatedAccount.wl_city" width="100" />              
      </row>
    </grid>
  </layoutxml>
  <querytype>0</querytype>
  <fetchxml>
    <fetch version="1.0" output-format="xml-platform" mapping="logical">
      <entity name="sb_statistics">
        <order attribute="sb_amount" descending="false" />
        <attribute name="sb_debtor" />
        <attribute name="sb_date" />
        <attribute name="sb_amount" />
        <link-entity name="account" from="accountid" to="sb_debtor" 
         alias="relatedAccount" link-type="outer">
          <attribute name="wl_towncity" />
          <link-entity name="wl_postalcode" from="wl_postalcodeid" 
           to="wl_postaltowncity" alias="relatedAddress" link-type="outer">
            <attribute name="wl_city" />
          </link-entity>
        </link-entity>
        <attribute name="sb_statisticsid" />
      </entity>
    </fetch>
  </fetchxml>
  <LocalizedNames>
    <LocalizedName description="Statistics and Address" languagecode="1033" />
  </LocalizedNames>
</savedquery> 

GridXML 是否仅限于显示主要实体和第一个链接实体的属性?

【问题讨论】:

  • 我无法谈论 GridXML 的任何限制,但 relatedAddress.wl_city 是您应该使用的正确别名。
  • 您能否通过高级查找创建个人视图并查看gridxml 在SQL 表中的样子?
  • @Andy 我只能从第一个链接实体添加列。
  • 这似乎是 GridXML 有史以来最严重的限制,我可以很好地显示来自 fetchxmlbuilder 的数据,它返回所有多嵌套链接实体及其所有字段的所有字段,包括 relatedAddress.wl_city 但是如何让该结果集在 GRidXML 中工作?到目前为止,我发现的唯一选择是采用相同的 FetchXML 并改用 RDL SSRS CRM 在线报告。但是这些报告太慢了。我想要快速查看的。

标签: dynamics-crm-2011 dynamics-crm fetchxml


【解决方案1】:

据我所知,这是不可能的,但请有人证明我错了。

GridXML 的一个限制似乎是只能包含来自第一个链接实体的属性,而不是任何嵌套的链接实体。

【讨论】:

  • 我仍然渴望找到一个真正可行的解决方案。 “没有答案”怎么可能是答案?
【解决方案2】:

在使用 link-type="inner" 嵌套链接时应该可以工作。

<entity name="sb_statistics">
    ...
    <link-entity name="account" from="accountid" to="sb_debtor" 
     alias="relatedAccount" link-type="outer">
      <attribute name="wl_towncity" />
      <link-entity name="wl_postalcode" from="wl_postalcodeid" 
       to="wl_postaltowncity" alias="relatedAddress" link-type="inner"> //link-type="inner"
        <attribute name="wl_city" />
      </link-entity>
    </link-entity>
    <attribute name="sb_statisticsid" />
  </entity>

【讨论】:

  • 那行不通。我也有完全相同的问题。所以我尝试了 link-type="inner" 它也没有工作。我试过禁用MetaDataBinding。我也没试过
  • @hamish 也许尝试使用高级查找 => 编辑列 => 添加列 => 选择嵌套实体 => 从嵌套实体中选择字段 => 好的 ok => 下载 Fetch XML => 显示请求
【解决方案3】:

我没有发现任何证据表明可以这样做。有或没有 link-type='inner' 设计师(2013 年)说,“relatedAddress.wl_city 列不再是有效列,因为它已作为列选项被删除。您需要删除此列,如果您想要,添加一个不同的。”

它不需要多次取消引用,这也不起作用。如果您转储 fetch 返回的 AttributeCollection 的 keyValuePairs,您将看到键是 relatedAddress.w1_city - 不是它的父项,也不是组合。

与 UI 一样,它只是显示布局仅限于根和子级,没有孙子,也没有后代。

【讨论】:

    【解决方案4】:

    我认为现在回答这个问题有点晚了,但也许有人来看这篇文章并觉得它有帮助。

    首先你应该知道的是,fetchxml 将只返回不为空的列,所以如果你正在查询其中没有数据的列,那么 fetchxml 会自动将其从结果集中删除。

    第二件事是,如果您有不同关系的不同表,那么别名将添加到列名中,因此在您的情况下relatedAccount.wl_towncityrelatedAddress.wl_city 是正确的,而不是relatedAccount.relatedAddress.wl_city。在您的示例中,您将别名放在一个不正确的名称之后。

    你应该知道的第三件事是,当嵌套结果返回时,类型是对象,但原始类型是AliasedValue,所以首先你必须将对象转换为AliasedValue。然后它准备好将其转换为OptionSetValue。之后你必须寻找有你想要的结果的.Value

    【讨论】:

      【解决方案5】:

      我让它像这样工作:我仍然有一个未解决的列标题问题。

           <fetch distinct='true'>
          <entity name='rdiac_riskobject'>
            <attribute name='rdiac_riskobjectid' />
            <attribute name='rdiac_name' />
            <attribute name='rdiac_riskobjectproduct' />
            <link-entity name='rdiac_riskobject_rdiac_propertydetail' from='rdiac_riskobjectid' to='rdiac_riskobjectid' intersect='true'>
              <link-entity name='rdiac_propertydetail' alias='pd1' from='rdiac_propertydetailid' to='rdiac_propertydetailid'>
                <attribute name='rdiac_valuestring' />
                <link-entity name='rdiac_propertysvconfig' from='rdiac_property' to='rdiac_propertyid'>
                  <filter>
                    <condition attribute='rdiac_svfield' operator='eq' value='100000000'/>
                  </filter>
                </link-entity>
              </link-entity>
            </link-entity>
            <link-entity name='rdiac_riskobject_rdiac_propertydetail'  from='rdiac_riskobjectid' to='rdiac_riskobjectid' intersect='true'>
              <link-entity name='rdiac_propertydetail' alias='pd2' from='rdiac_propertydetailid' to='rdiac_propertydetailid'>
                <attribute name='rdiac_valuestring' />
                <link-entity name='rdiac_propertysvconfig' from='rdiac_property' to='rdiac_propertyid'>
                  <filter>
                    <condition attribute='rdiac_svfield' operator='eq' value='100000001'/>
                  </filter>
                </link-entity>
              </link-entity>
            </link-entity>
          </entity>
        </fetch>
      
        <grid name='resultset' object='10139' jump='rdiac_riskobjectproduct' select='1' preview='0' icon='1' >
          <row name='result' id='rdiac_riskobjectid' >
            <cell name='rdiac_riskobjectproduct' width='100' />
            <cell name='pd1.rdiac_valuestring' width='200' />
            <cell name='pd2.rdiac_valuestring' width='200' />
          </row>
        </grid>
      

      【讨论】:

        猜你喜欢
        • 2020-10-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-12
        • 1970-01-01
        • 2017-08-31
        • 2021-05-29
        相关资源
        最近更新 更多