Announcements
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!
Ok, so even with FetchXML I still need to declare an EntityCollection to get my record...
Thank you for your help !
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.
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
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)
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156