4

我想要一个显示来自 3 个实体的属性的视图:
Statistics 具有对 Account 的查找,Account 具有对 Address 的查找。

该视图是关于统计的,我想要所有 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 是否仅限于显示主要实体和第一个链接实体的属性?

4

5 回答 5

5

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

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

于 2013-11-19T07:29:47.680 回答
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>
于 2016-04-04T14:20:08.630 回答
2

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

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

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

于 2016-04-19T03:39:38.803 回答
0

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

您应该知道的第一件事是,fetchxml 将仅返回不为空的列,因此,如果您正在查询其中没有数据的列,那么 fetchxml 会自动将其从结果集中删除。

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

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

于 2015-01-06T13:37:07.203 回答
0

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

     <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-08-12T07:53:48.910 回答