Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Fetch Distinct Record from WEB API - CRM V9

Posted on by Microsoft Employee

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

  • Wayne_AASP Profile Picture
    Wayne_AASP 10 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

    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.

  • Suggested answer
    CRMJetty Profile Picture
    CRMJetty 3,508 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

    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'.

  • Suggested answer
    XM-22040801-0 Profile Picture
    XM-22040801-0 11 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

    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

  • Wayne_AASP Profile Picture
    Wayne_AASP 10 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

    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.

  • oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

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

  • Suggested answer
    naresh babu Profile Picture
    naresh babu 425 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

    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>

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Fetch Distinct Record from WEB API - CRM V9

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

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans