Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

What is wrong with this query regarding DISTINCT field retrieval

Posted on by Microsoft Employee

I got the following response from odata rest API when using distinct, so that I can pull the unique values of a specific column within the contact entity type.

api/data/v8.0/contacts?fetchXml=<fetch mapping="logical" distinct="true" version="1.0">

<entity name="contact">
<attribute name="leadsourcecode" />
</entity>
</fetch>

'select' and 'expand' cannot be both null or empty."

Does any one know how to get unique values a specific columns in LCMS 2016 web API?

Thanks in advance

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: What is wrong with this query regarding DISTINCT field retrieval

    In FetchXML query you should have at least one attribute from entity which is not null to resolve this issue like Id.

    <attribute name='contactid' />

    if that works mark as verified.

    Thank you,

    Dhruv.

    Microsoft Certified Professional

  • Nirmal_CRM Profile Picture
    Nirmal_CRM 175 on at
    RE: What is wrong with this query regarding DISTINCT field retrieval

    Hi Mohammad,

    Were you able to solve this issue ? If yes, could you please let me know how ?

    Regards,

    Nirmal

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: What is wrong with this query regarding DISTINCT field retrieval

    Thank you Alex. Same here no documentation about this limitation.

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: What is wrong with this query regarding DISTINCT field retrieval

    Hi Mohammed,

     exactly the same request works fine in 365, so it might be some sort of limitation in 2016, but I could not find anything related to it here:

    msdn.microsoft.com/.../mt628816.aspx

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans