• Resolved kimineko

    (@kimineko)


    Hey there,

    probably an easy question, but I just cannot wrap my head around how to display data of a record from a field in a related entity.

    Using a view the data is displayed, however, I would like to customize the way it gets displayed, hence my question.

    D365 Info:
    The view displays records of the entity “ud_tutorial”. There is a 1:1 connection to the entity “udc_seminartype” – and for what its worth, the lookup field on the entity “ud_tutorial” is “udc_seminartypeid”. The value that I am trying to get is “udc_title” (from said entity “udc_seminartype”).

    The view:

    [msdyncrm_twig]
    {% view entity="ud_tutorial" name="My View" count="15" cache="PT60M" %}
    {% endview %}
    [/msdyncrm_twig]
    {% for recordId, record in entityview.rows %}
    <tr>
    <td>{{ record["udc_seminartypeid.udc_title".value ]}}</td>
    </tr>
    {% endfor %}

    What would be the correct syntax in this case? I assumed that it would work similarly to Power Automate, where I would write down the path from the original entity through the lookup field to the field that I need.

    Maybe you could point me in the right direction and/or where to look in the Twig documentation?

    Kind regards
    Kim

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author alexacrm

    (@alexacrm)

    Hi Kim,

    to get the columns from linked tables you need to know the alias. Easiest way is to load view definition in advanced find then click Download FetchXml. The correct reference will be alias.fieldname.

    For example, I use “All Invoices” view that has customer’s email address as a column. When I download fetchxml I get this:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="invoice">
        <attribute name="name" />
        <attribute name="totalamount" />
        <attribute name="customerid" />
        <attribute name="statuscode" />
        <attribute name="invoiceid" />
        <order attribute="name" descending="false" />
        <link-entity name="contact" from="contactid" to="customerid" visible="false" link-type="outer" alias="invoicecustomeridcontactcontactid">
          <attribute name="emailaddress1" />
        </link-entity>
      </entity>
    </fetch>

    So in this case the correct reference is record["invoicecustomeridcontactcontactid.emailaddress1"].value.

    I know it’s odd and probably can change and that’s why in more complex scenarios recommendation is to use {% fetchxml %} tag instead. You can define exactly what you need, built something that is not available in views, and have some finesse in your queries.

    HTH
    George

    Find the plugin useful? Please leave a review!

    Thread Starter kimineko

    (@kimineko)

    Hi George,

    thank you very much for the quick response. That solves my problem indeed ??

    Kind regards
    Kim

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Surfacing data from related entities using custom template’ is closed to new replies.