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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Fetch Distinct Record from WEB API - CRM V9

(0) ShareShare
ReportReport
Posted on by

Dear Friends

Please guide me how I will fetch the DISTINCT records from Entity using WEB API

Kind Regards

Anil

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    As far as I know, you can only do this by submitting the query as a Fetch and specifying distinct="true" in the FetchXML

  • Suggested answer
    naresh babu Profile Picture
    425 on at

    Hi Anil,

    Try this syntax

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

     <entity name="incident">

       <attribute name="incidentid" />

       <attribute name="title" />

       <attribute name="customerid" />

       <attribute name="statuscode" />

       <attribute name="caseorigincode" />

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

       <filter type="and">

         <condition attribute="ownerid" operator="eq-userid" />

         <condition attribute="statecode" operator="eq" value="0" />

       </filter>

     </entity>

    </fetch>

  • oliver.rodrigues Profile Picture
    4,052 on at

    are you using within the Portals through oData? is this Portals or CRM? did you tag "Portals" by mistake maybe? can you please untag?

  • Wayne_AASP Profile Picture
    10 on at

    It really needs to be possible to do this without XML. XML parsing is very slow. Does anyone know if a JSON is possible or a direct query instead? Not really understanding why a simple $distinct='true' isn't possible or something like that in a regular query.

  • Suggested answer
    XM-22040801-0 Profile Picture
    11 on at

    Hello,

    Would a group by be suitable for you?

    Group by with $apply: /api/data/v9.2/accounts?$apply=groupby((name,accountnumber))

    Source : docs.oasis-open.org/.../odata-data-aggregation-ext-v4.0-cs01.html

  • Suggested answer
    CRMJetty Profile Picture
    3,514 on at

    Hello Anil,

    - Yes you can use group by attribute to get distinct records.
    - Here we fetch contact with distinct lastname.
    => /api/data/v9.0/contacts?$apply=groupby((lastname,firstname))

    - Also you can use fetchXml to get distinct record by using distinct='true'.

  • Wayne_AASP Profile Picture
    10 on at

    since XML is slow, it is hard to say where the breaking point is on just getting everything and creating a distinct list yourself. It would be much better to just have a $&Distinct='true' in the URL.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans