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 365 | Integration, Dataverse...
Answered

(PLUGIN/C#) Can we use Retrieve method to retrieve a record with a QueryExpression ?

(0) ShareShare
ReportReport
Posted on by 15

Hi all, really fast question !

I have managed to get a filtered record by using RetrieveMultiple and by specifying my filtering criteria in a QueryExpression/FilterExpression.

It's working fine but I have the feeling that it must be a cleaner solution to archive this !

I don't need to retrieve more than one record, I just need to confirm that a record with value "x" in field "y" exist in my DB.

Can I do that with a simple Retrieve() ? 

Or in other words, what's the most proper way to do what I want to do ?

Thanks for help!

I have the same question (0)
  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    if you need to check by a field value and not by ID, RetrieveMultiple is the only way.

    Retrieve requires the ID and it throws an exception if the record is not found, from this point doing a RetrieveMultiple is also better because you check the result Entities count (0, 1 or more than 1)

  • DynaMoX Profile Picture
    15 on at

    I keep it open to see if eventually somebody have a "secret joker", but thank you anyway for your help! I will mark your answer as a solution if nobody can "find better" !

    PS: A friend have said to me that I could use directly a FetchXML in my code but we didn't had the time to go into details, if somebody know what he means and have an example, please don't wait for a special invitation before sharing your knowledge ;) Thanks

  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    in your scenario FetchXML is equivalent to a QueryExpression, with C# the code will be:

    service.RetrieveMultiple(new FetchExpression(fetchXMLquery));

    I hope you can find a "secret joker" but the platform for this component is the same in the last 13 years. You can try some tricks if the field can be an alternate key (so unique) and doing a retrieve by the alternate key.

  • DynaMoX Profile Picture
    15 on at

    Ok, so even with FetchXML I still need to declare an EntityCollection to get my record...

    Thank you for your help !

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 53 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans