This is my first ever post with D365 Portals. I will bring up more interesting ones as we go along. Today I am going to talk about how you can customize your portal’s web template to use CRM fetch query with liquid.
D365 CRM provides an ability to categorize your articles using ISH (Interactive Service Hub). Those categories are used as tags and then displayed on D365 Portals as a list to browse the articles from. I will showcase how to modify the existing template and using FetchXML instead.
<fetch mapping="logical" returntotalrecordcount="true" count="{{ count }}">
<entity name="category">
<attribute name="categorynumber" />
<attribute name="title" />
<attribute name="createdon" />
<attribute name="categoryid" />
<order descending="false" attribute="title" />
</entity>
</fetch>
<!-- OLD Category Display -->;
{% extends 'layout_1_column' %}
{% block main %}
{% include 'Page Copy' %}
{% assign category_url = sitemarkers['Category'].url %}
{% assign count = count | default: 0 %}
{% assign categories = knowledge.categories | top_level: count %}
{% if categories %}
<div class="list-group unstyled">
{% for category in categories %}
<!-- <a href="'id', category.categorynumber }}" class="list-group-item">-->
{{ category.title }}
</a> -->;
{% endfor %}
</div>
{% endif %}
<strong><!-- OLD Category Display -->;</strong>
<!-- New Category Display -->;
<div class="list-group">
{% fetchxml categories_query %}
{% endfetchxml %}
{% assign categories = categories_query.results.entities %}
{% if categories %}
<div class="list-group">
<h4 class="list-group-item-heading">Articles by Categories</h4> <br /> <br />
{% for category in categories %}
<a class="list-group-item" href="'id', category.categorynumber }}{{ category.categorynumber | escape }}">{{ category.title | escape }}</a>
{% endfor %}
</div>
{% endif %}
<strong><!-- End New Category Display -->;</strong>
</div>;
{% endblock %}
You will see the categories are now sorted in order.