Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Getting distinct values from fetchXML using Liquid

Posted on by 25

I have a fetchXML that returns data like this 

sample-data.PNG

wondering if I can get distinct group IDs using the same fetchXml by using some filter or otherwise have to write a separate query to get distinct groups?

*This post is locked for comments

  • Verified answer
    Inogic Profile Picture
    Inogic 24,094 on at
    RE: Getting distinct values from fetchXML using Liquid

    Hi Usmani,

    “if I can get distinct group IDs using the same fetchXml by using some filter” – No, you cannot filter it using Fetch XML.

    You have to write separate query to get distinct group.

    For e.g.:

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

     <entity name="group">

       <attribute name="gropupid" />

     </entity>

    </fetch>

    Hope this helps.

    Thanks!

  • Verified answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: Getting distinct values from fetchXML using Liquid

    do you need the list Groups or you just to render as a group

    if you need the list perhaps the easiest way is repeating the fetch only retrieving the GroupId and adding the distinct as per Adrian indication

    if your looping and want to render as a group, I would suggest simply storing in a variable the last GroupId and keep verifying if it has changed

    worst case scenario you can do 2 fetchs.. one for the groups.. while looping, another fetch filtering by the group.. but this will decrease the performance

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: Getting distinct values from fetchXML using Liquid

    Hi Usmani,

    Use this syntax in your Fetch XML definition.

    fetch mapping='logical' distinct='true'>

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