web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

{Portals} How to access related entity field in liquid template

(0) ShareShare
ReportReport
Posted on by 55,410 Moderator

I am using fetch xml/ liquid to retrieve the entity details. This works fine and I can display the retrieved fields from the main entity. However I also have a linked entity and want to display the field from that as well. I tried different combination but nothing worked.

{{ result.<alias>.<fieldname> | escape }} - not working
{{ result.<fieldname> | escape }} - not working
{{ result.<related entity schema name>.<fieldname> | escape }} - not working
{{ <alias>.<fieldname> | escape }} - not working

Any thoughts?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Inogic Profile Picture
    709 on at

    Hi Ravi,

    1. Below is the fetch xml that contains link entity of account

     

    {% fetchxml contact_account_query %}

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

      <entity name="contact">

        <attribute name="fullname" />

        <attribute name="telephone1" />

        <attribute name="contactid" />

        <order attribute="fullname" descending="false" />

        <filter type="and">

          <condition attribute="firstname" operator="eq" value="david" />

          <condition attribute="lastname" operator="eq" value="beckham" />

        </filter>

        <link-entity name="account" from="accountid" to="parentcustomerid" visible="false" link-type="outer" alias="ai">

          <attribute name="name" />

          <attribute name="websiteurl" />

          <attribute name="telephone1" />

        </link-entity>

      </entity>

    </fetch>

    {% endfetchxml %}

     

    2. To get alias value from link entity use below code

    {% for result in contact_account_query.results.entities %}

      

    Contact Name : {{result.fullname}}<br/>

    Account Name : {{result['ai.name']}} (this is alias value)

     

    {% endfor %}

     

    so to get alias value use {{result['ai.name']}}

    ai.png

    Thanks!

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Thanks it worked :)

  • ammi64 Profile Picture
    87 on at

    Hi Ravi,

    can you please help me out on how to access  related entity field in liquid template, need an urgent response from your end.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Did you try the above suggestions, that (getting aliased value) worked for me.

  • ammi64 Profile Picture
    87 on at

    I just need to access the related account fields of the contacts through liquid code. I am able to show up the name and id using the following liquid tag:

    {{user.parentcustomerid.id}}

    {{user.parentcustomerid.name}}

    but not able to access the other fields

  • ammi64 Profile Picture
    87 on at

    parentcustomerid is an entity reference object. I want to access the account fields related to contacts of that account to show up in the copy area on the webpage in MSCRM portal.

  • Suggested answer
    Nicholas Hayduk Profile Picture
    2,863 on at

    You are correct - parentcustomerid is the entity reference object, which only gives you ID and name.  To get access to the entire entity, use the relationship name instead of the name of the lookup field, like so:

    user.contact_customer_accounts.address1_line1

    Nick

  • ammi64 Profile Picture
    87 on at

    Thanks a lot Nicholas. Now I am able to access the account fields.

  • ammi64 Profile Picture
    87 on at

    Hi Nicholas when I am logged in with a different user I am not able to see the account fields.

  • ammi64 Profile Picture
    87 on at

    Hi Nicholas,

    user.contact_customer_accounts.address1_line1 this works only when my user is logged in as a administrator on the portal but it dosen't work for the users assigned authenticated web roles. Any solution to this ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans