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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Suggested answer

Render an entity view or entity list with liquid in portal

(1) ShareShare
ReportReport
Posted on by

I am working with one of the dynamics portals, and I'm customizing a web template. I'm using some liquid expressions to show certain content based on the users' web role. I am able to display certain charts based on a specific web role, but for a different web role I'd like to show an entity list/entity view. I initially tried using this liquid expression: 

{% entitylist name: 'myList' %}

Loaded entity list {{ entitylist.adx_name }}.

{%endentitylist%}

This appears to load the entity list, but does not render it. I'd like to use liquid to render it the way it would be rendered if I used the configuration to append the entity list to the page. The reason I'm not just doing it like this is, as I said before, I need it to show only if the user has a specific web role. 

Thanks in advance for any help.

*This post is locked for comments

I have the same question (0)
  • Irena Benja Profile Picture
    414 on at
    RE: Render an entity view or entity list with liquid in portal

    This is an old question and I am sure that you found you a solution so far :D

    To everyone coming across this:

    You can use a similar custom Template

     {% fetchxml webroleList %}
      <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="adx_webrole">
        <attribute name="adx_webroleid" />
        <attribute name="adx_name" />
        <order attribute="adx_name" descending="false" />
         <link-entity name="adx_webrole_contact" from="adx_webroleid" to="adx_webroleid" visible="false" intersect="true">
          <link-entity name="contact" from="contactid" to="contactid" alias="ab">
            <filter type="and">
              <condition attribute="contactid" operator="eq" value="{{user.id}}" />
            </filter>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>
    {% endfetchxml %}

    {% for item in webroleList.results.entities %} {% if item.adx_name == 'WebRole1' %} {% include "entity_list" key:"Entity1" %} {% endif %} {% endfor -%}


  • Gaurav_Pandey09 Profile Picture
    197 on at
    RE: Render an entity view or entity list with liquid in portal

    HI Ira,

    Is the key name same that we configure in the entity list configuration page on entity logical name?

  • Mahendar Pal Profile Picture
    45,095 on at
    RE: Render an entity view or entity list with liquid in portal

    Yes this key is the key which is configured under entity list. you can use this key to refer particular entity list.

    Hope it will help.

  • Gaurav_Pandey09 Profile Picture
    197 on at
    RE: Render an entity view or entity list with liquid in portal

    used the below code to fetch user from CRM. But I dont get any value returned in the template but at the same time I could see the record in Advanced Find.

    {% extends 'Layout 1 Column' %}

    {% block main %}

     {% include 'Page Copy' %}

     Hey {{user.id}}

     {% fetchxml webroleList %}

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

     <entity name="adx_webrole">

       <attribute name="adx_webroleid" />

       <attribute name="adx_name" />

       <attribute name="createdon" />

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

       <link-entity name="adx_webrole_contact" from="adx_webroleid" to="adx_webroleid" visible="false" intersect="true">

         <link-entity name="contact" from="contactid" to="contactid" alias="ab">

           <filter type="and">

             <condition attribute="contactid" operator="eq" value="{{user.id}}" />

           </filter>

         </link-entity>

       </link-entity>

     </entity>

    </fetch>

    {% endfetchxml %}

    {% for item in webroleList.results.entities %}  

    {% if item.adx_name == 'Administrators' %}  

           {% include "entity_list" key:"AdminEntityList" %}

           {% endif %}      

       {% endfor -%}

    <div class="page-metadata clearfix">

       {% editable snippets "Social Share Widget Code Page Bottom" type: 'text' %}

     </div>

    {% endblock %}

  • Irena Benja Profile Picture
    414 on at
    RE: Render an entity view or entity list with liquid in portal

    Hello,

    It should work if you also use on the key the entity logical name.

    And you have set the entity permission? make sure you are working with a user that has access to it.

  • Suggested answer
    sandeepstw Profile Picture
    4,601 on at
    RE: Render an entity view or entity list with liquid in portal

    Hi,

    For roles use like -

    {% if user.roles contains 'This Role Name' %}

    {% include "entity_list" key:"EntityListName" %}

    {% endif %}

  • Gaurav_Pandey09 Profile Picture
    197 on at
    RE: Render an entity view or entity list with liquid in portal

    Hi Sandeep,

    I tried this and it worked. I have one another question. I created a view where i gave Owner equals current user. But it doesn't render any record in portal although same view gives me record in CRM.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Render an entity view or entity list with liquid in portal

    Hi Gaurav,

    When you create a view saying equals current user, you are specifying the currently logged in crm user whereas in portal the users are contact record. Portal runs on the context of System user thus you won't get any records in portal.

    If you wish to see only records for the logged in user, you can either configure the web role or you can apply filter in the entity list.

    Also, it is always advisable to create new thread for new questions for various reasons.

  • AAVI21 Profile Picture
    25 on at
    RE: Render an entity view or entity list with liquid in portal

    Hi - I am trying below piece of code on custom web template to show charts and views for different web role, but unfortunately it is not work. Please suggest what mistake I am doing in below code.

    <div class="container">
    {% fetchxml getWebRoleList %}
    <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
    <entity name='adx_webrole'>
    <attribute name='adx_webroleid' />
    <attribute name='adx_name' />
    <attribute name='createdon' />
    <order attribute='adx_name' descending='false' />
    <link-entity name='adx_webrole_contact' from='adx_webroleid' to='adx_webroleid' visible='false' intersect='true'>
    <link-entity name='contact' from='contactid' to='contactid' alias='ab'>
    <filter type='and'>
    <condition attribute='contactid' operator='eq' value='{{user.id}}' />
    </filter>
    </link-entity>
    </link-entity>
    </entity>
    </fetch>
    {% endfetchxml %}
    {% assign webRoleList = getWebRoleList.results.entities %}
    {% for item in webRoleList %}
    {% if item.adx_name == 'Administrators' %}
    <div class="row">
    <div class="col-md-9 ">
    {% block main %}
    {% if page.adx_entitylist %}
    {% include 'entity_list' key:page.adx_entitylist.id %}
    {% endif %}

    {% if page.adx_entityform %}
    {% entityform id: page.adx_entityform.id %}
    {% endif %}

    {% if page.adx_webform %}
    {% webform id: page.adx_webform.id %}
    {% endif %}
    {% endblock %}
    </div>
    <div class="col-md-3 small">
    <!-- Cases by Status -->
    {% chart id:"C0307D90-224A-E911-A97B-000D3AF24D43" viewid:"EA900F65-C94E-E911-A976-000D3AF02D26" %}
    {% chart id:"A49B7B81-204A-E911-A97B-000D3AF24D43" viewid:"EA900F65-C94E-E911-A976-000D3AF02D26" %}
    </div>

    </div>
    {% endif %}
    {% if item.adx_name == 'Agency Agent' %}
    <div class="row">
    <div class="col-md-9 ">
    {% block main %}


    {% if page.adx_entitylist %}
    {% include 'entity_list' key:page.adx_entitylist.id %}
    {% endif %}

    {% if page.adx_entityform %}
    {% entityform id: page.adx_entityform.id %}
    {% endif %}

    {% if page.adx_webform %}
    {% webform id: page.adx_webform.id %}
    {% endif %}
    {% endblock %}
    </div>
    <div class="col-md-3 small">
    <!-- Cases by Status -->
    {% chart id:"C0307D90-224A-E911-A97B-000D3AF24D43" viewid:"EA900F65-C94E-E911-A976-000D3AF02D26" %}
    {% chart id:"A49B7B81-204A-E911-A97B-000D3AF24D43" viewid:"EA900F65-C94E-E911-A976-000D3AF02D26" %}
    </div>
    </div>

    {% endif %}
    {% endfor %}
    </div>

    Thanks

    Aavi

  • Suggested answer
    oliver.rodrigues Profile Picture
    4,052 on at
    RE: Render an entity view or entity list with liquid in portal

    you don't need that to get the current user role.. you can use:

    {% if user.roles contains 'Administrators' %} User is an administrator. {% endif %}

    this seems to be quite an old thread.. I would suggest creating a new one if there is any other issues on your case

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans