locked
FetchXML View to Include Attributes from Nested Link-Entity RRS feed

  • Question

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



    • Edited by Bvrce Monday, November 18, 2013 1:14 PM
    Monday, November 18, 2013 1:13 PM

All replies

  • Hi

    Please let me know whether it is possible or not in CRM 2013 , I am trying to create a customize view and add a column of the nested linked entity to the layoutxml , Do we have any other alternatives to make nested linked entity columns visible in the view.

    Thursday, June 15, 2017 3:59 PM
  • This level of nesting doesn't support out of box views, you can link upto Account without any customization however to pick the addres field you cannot use the fetch. Other suggestion would be some custom grid control or to populate the field required in account entity which would be duplication of fields.

    If my response answered your question, please "mark the response as an answer" and also "vote as helpful". Regards, Hari. www.crm2011byhari.blogspot.com

    Monday, June 19, 2017 5:45 AM