Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Suggested answer

Check if there are records created by certain user

Posted on by 5

Hi all

I need to check if there records of entity created by certain user (createdby equals userId). I suppose query with aggregate count (webapi or fetchXML, doesn't matter) is OK. If count > 0 then there are records, pretty obvious.

I wonder if there is some more efficient way to do this. Like Any in LINQ, so that it doesn't go through all collection after finds first element which satisfies the condition.

I found Any function in WebAPI. But as I understand it is only applicable for collection-valued properties of entity

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: Check if there are records created by certain user

    Hi,

    Use Count aggregate option in fetchxml to retrieve record count based your filter criteria. Then check if count>0.

    docs.microsoft.com/.../use-fetchxml-aggregation

    Please mark my answer verified if i were helpful

  • Suggested answer
    sdfasdf Profile Picture
    sdfasdf 840 on at
    RE: Check if there are records created by certain user

    If you just need to determine whether a particular user created records or not, you may want to limit this query to retrieve the top 1 result. If any results are retrieved, then you can be certain that the user created at least one record. With FetchXML, you can you the top="1" attribute.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans