Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FetchXML View to Include Attributes from Nested Link-Entity

I would like to have a view that show attributes from 3 entities:
Statistics has a lookup to Account and Account has a lookup to Address.

The view is on Statistics and I want attributes from all 3 entities; is this even possible?

The problem is with the GridXML.
I want to include the attribute wl_city in the GridXML.

This is the FetchXML with link-entities:

<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>

When I change the GridXML as below this error is displayed when the view is opened:
"To use this saved query, you must remove criteria and columns that refer to deleted or non-searchable items"

  <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>

The below GridXML shows this error when the view is opened:
"Unexpected Error An error has occured".

  <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>

The GridXML below results in this error being shown when the view is opened:
"To use this saved view, you must remove criteria and columns that refer to deleted or non-searchable columns".

  <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>

This saved query works, but it only includes attributes from the primary entity and the first link-entity.

<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> 

Is GridXML limited to showing only attributes from the primary entity and the first link-entity?

like image 689
Bvrce Avatar asked Jan 12 '23 21:01

Bvrce


2 Answers

This is not possible, according to the best of my knowledge, but please someone prove me wrong.

A limitation of GridXML appears to be that attributes can only be included that are from the first link-entity, not any nested link-entities.

like image 117
Bvrce Avatar answered Apr 06 '23 00:04

Bvrce


It should work when using link-type="inner" for nested link.

<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>
like image 39
Niels Steenbeek Avatar answered Apr 06 '23 00:04

Niels Steenbeek