condition of FetchXml query not taken account of

659 views Asked by At

We are currently installing blogs on our Dynamics 365 Portal. Wanting to modify the layout of the posts we recreacted a template based on this structure : https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/liquid-templates/objects/blogs/

Because the adx "post" object doesn't contain tags, we had to use a fetchxml query to get them.

The problem is the query retrieve all the tags : enter image description here Only the Général tag should be showing on the first post only.

Full code :

{% assign blog = blogs['Actualités et annonces'] %}
{% assign posts = blog.posts %}
<div class="col-md-8">
    <div class="content-panel panel panel-default">
        <div class="panel-heading">
            {% assign sitemarker = sitemarkers["Blog Home"] %}
            {% assign snippet = snippets["Home Blog Activity Heading"] %}
            <a class="pull-right" href="{{sitemarker.url}}"> All Blogs </a>
            <h4>
                <a class="feed-icon fa fa-rss-square" href="{{ blogs.feedpath }}">
                    {{ snippet.adx_value }}
                </a><div class="grid-container">
                    {% for post in posts.all %}
                    <div class="grid-item">
                        <a class="image-header" href="{{ post.url }}">
                            {% if post.new_category %}
                            {% assign category = entities.new_vignette[post.new_category.id] %}
                            {% assign imgpath = category.new_path %}
                            {% elsif post.new_vignette %}
                            {% assign imgpath = post.new_vignette %}
                            {% else %}
                            {% assign imgpath = "../pocfabien/avarap-entete" %}
                            {% endif %}
                            <img class="img-responsive img-post" src="{{imgpath}}">
                        </a>
                        <div class="content-header">
                            <h4 class="list-group-item-heading">
                                <a href="{{ post.url }}">{{ post.title }}</a>
                            </h4>
                            <br />
                            <abbr>{{ post.publish_date }}</abbr>
                        </div>
                        <div class="content-preview">
                            {{post.adx_summary}}
                        </div>
                        <div>
                            {% fetchxml tags %}
                            <fetch>
                                <entity name="adx_tag">
                                    <attribute name="adx_name" />
                                    <attribute name="adx_tagid" />
                                    <link-entity name="adx_blogpost_tag" from="adx_tagid" to="adx_tagid" intersect="true">
                                        <filter>
                                            <condition attribute="adx_blogpostid" operator="eq" value="{{ post.adx_blogpostid }}" />
                                        </filter>
                                    </link-entity>
                                </entity>
                            </fetch>
                            {% endfetchxml %}
                            {% for tag in tags.results.entities %}
                                {{ tag.adx_name }}
                                {% unless forloop.last %} | {% endunless %}
                            {% endfor %}
                        </div>
                        <img class="plusign" src="plusign.png">
                    </div>
                    {% endfor %}
                </div>
            </h4>
        </div>
    </div>
</div>

PS : if you have a solution to retrieve n:n relationship entities without a fetchXml query I am all ears.

2

There are 2 answers

0
James Wood On

I don't think your FetchXML is correct. If you use Advanced Find to create the FetchXML its pretty straight forward. Here is an example for account to lead, note the additional link entity across the many to many intersect table.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
  <entity name="account">
    <attribute name="name" />
    <link-entity name="accountleads" from="leadid" to="accountid" visible="false" intersect="true">
      <link-entity name="lead" from="leadid" to="accountid" alias="ac">
        <filter type="and">
          <condition attribute="leadid" operator="eq" uiname="Test Lead" uitype="lead" value="{FC271420-B2BB-4A87-B852-1DF7CF4B4F3E}" />
        </filter>
      </link-entity>
    </link-entity>
  </entity>
</fetch>
0
Marcelo Acosta On

I think that the XML is off, try making the wanted filter in an advanced search and download the FetchXML

Is in spanish, but the icon is the same

Hope it helps

M.Acosta.D