Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Render an entity view or entity list with liquid in portal

    I think you are looking for this.

    //Include an entity-list using liquid-tags.
    //Pass the name of the entity-list.
    {% include 'entity_list' key:'Display Contact Lists' %}



    You can also check this Post link, Wil be helpful.

    https://sank8sinha.wordpress.com/2020/07/27/liquid-code-tipscode-snippets-for-dynamics-portal/?wref=tp

  • Narendra Sunkara Profile Picture
    Narendra Sunkara 465 on at
    RE: Render an entity view or entity list with liquid in portal

    Hi Ira,

    I have got similar requirement. I need to show different entity lists based on the role and when I was searching I found this, Where do I need to include this code exactly. Is there any other refined code these days.

    Regards,

    Babu

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 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

  • AAVI21 Profile Picture
    AAVI21 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
    RaviKashyap Profile Picture
    RaviKashyap 55,410 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.

  • Gaurav_Pandey09 Profile Picture
    Gaurav_Pandey09 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
    sandeepstw Profile Picture
    sandeepstw 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 %}

  • Irena Benja Profile Picture
    Irena Benja 412 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.

  • Gaurav_Pandey09 Profile Picture
    Gaurav_Pandey09 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 %}

  • Mahendar Pal Profile Picture
    Mahendar Pal 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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,329 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans