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)

Liquid, How to filtering lookup field in fetchxml

(0) ShareShare
ReportReport
Posted on by
Bellow the follow code.
{% assign contactId = user.contactid %}
{% fetchxml myentity_Query %}
<fetch version="1.0" mapping="logical">
<entity name="myentity">
<attribute name="myentitytext" />
<attribute name="myentity_contactid" />
<link-entity name="contact" to="myentity_contactid" >
<filter type="and">
<condition attribute="contactid" operator="eq" value="{{ contactId }}" />
</filter>
</link-entity>
</entity>
</fetch>
{% endfetchxml %}
myentity (many to one) contact
use
myentity_contactid link contactid
contactid field is contact entity's primary key.
I cannot load the result with the follow code.
{% for item in myentity_Query.results.entities %}
<div class="item">
{{ item.myentitytext}}
</div>
{% endfor %}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at

    Hi Evan,

    Here is the correct format to fetch data using lookup condition.

    For Demonstration, I have fetched all the Cases whose Customer is 'Arpit Shrivastava'

    {% assign contactId = user.contactid %}

    {% fetchxml my_query %}

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

      <entity name="incident">

        <attribute name="title" />

        <attribute name="ticketnumber" />

        <attribute name="createdon" />

        <attribute name="incidentid" />

        <attribute name="caseorigincode" />

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

        <filter type="and">

          <condition attribute="customerid" operator="eq" uiname="Arpit Shrivastava" uitype="contact" value="{{ contactId }}" />

        </filter>

      </entity>

    </fetch>

    {% endfetchxml %}

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

    <script type="text/javascript">

    alert('{{ result.ticketnumber}}');

    </script>

      {{ result.ticketnumber | escape }}

    {% endfor %}

    Hope it helps,

    If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.

     

    Cheers

    Arpit

    https://arpitmscrmhunt.blogspot.in

  • Community Member Profile Picture
    on at

    Hi Arpit,

    Thanks for your help.

  • Community Member Profile Picture
    on at

    Hi Arpit,

    using your code the outcome of alert('{{ result.ticketnumber}}'); is written beneath the rest of my entityform. This already works. There are just those records displayed, which I want to be there.

    What I´m trying to achieve is:

    Apply this filter to a lookup field.

    Right now when I open the lookup field "parentaccount" I can see every account saved in the crm. I want to set this fetchxml filter here, so that I can only see the accounts which i filtered in the fetchxml.

    How can I achieve this?

    Greetings

    Roman

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