Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Nested Group By In Liquid Template Dynamics 365 Portal

Posted on by 13,756

Hi Expert,

I am struggling to get nested grouped by data using fetch xml in portal liquid template.

for e.g first group by on Product entity 

Product A, Product B. Within that I have some other lookup and can have different values under the Product A or B.

So the structure Goes like this:

Product A 

   -Type - Raw  

          Manufactured Date : 05/01993

   -Type - ReadyMade

          Manufactured Date : 05/01977

   -Type Raw

          Manufactured Date : 05/07/1930

Should simply be :

Products A ( first Grouby)

     Type - Raw

       Manufactured Date : 05/01993
       Manufactured Date : 05/07/1930

     Type - ReadyMade

       Manufactured Date : 05/01977

Below code is to get the first level grouping - not sure how to proceed with other nested group.

{

fetch xml here///

}

{% assign groups = my_query.results.entities | group_by: 'group by field' }

{% for group in groups %}
 {{ group.key }}
{% for item in group.items %}

*This post is locked for comments

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: Nested Group By In Liquid Template Dynamics 365 Portal

    is "type" an option set? can you try this:

    {% assign group_by_channel = product.items | group_by:'type.value' %} // second group

  • Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Nested Group By In Liquid Template Dynamics 365 Portal

    Hi Mahender,

    I actually tried it. the first group is fine but for the next one it is just sorting the records. May be i am not doing it right?

    {% assign consent_records = my_query.results.entities | group_by: 'product.name' %}     // first group
    
    {% for product in consent_records %}
    <h1><u> {{ product.key }}</u></h1>
    
    <script type="text/javascript"> 
    console.log(_.groupBy(consent_records,''type)); 
    </script>
    
    {% assign group_by_channel = product.items | group_by:'type' %} // second group --- not working
    {% for channel in group_by_channel %}
    
    {% for result in channel.items %}
    
    <div name="main-content" style='margin-left: 300px; max-width: 800px;'> 
    <h2>Channel: {{ result.type.name }} </h2>
    <h2>{{ result.indskr_emailaddress.name }}</h2>
    <h2>{{ result.indskr_addressname }} </h2>
    <h2>{{ result.indskr_phone }}</h2>
    <h2>{{ result.indskr_campaign.name }}</h2>
    <button id = '{{result.recordid}}' onclick='executeWorkflow(this.id)'> Opt Out</button>
    </div>
  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Nested Group By In Liquid Template Dynamics 365 Portal

    Hi,

    Never got such requirement but did you try to use nested loop to access your groups like this

    www.siteleaf.com/.../advanced-liquid-group-by

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans