Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

finding records programmatically only show 50k records

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I had written code to get the emails record in crm online, however if the records are more than 50K, error will be thrown. Is there a way to get all the emails records without running into exception (Exception error: "AggregateQueryRecordLimit exceeded. Cannot perform this operation.")?

code snippet:

string returnstatus = "";
var xmlAllemails = @"
<fetch distinct='false' mapping='logical' aggregate='true'>
<entity name='email'>
<attribute name='subject' alias='subject_count' aggregate='count'/>
</entity>
</fetch>";

int countAllemails = 0;

try
{
var resultAllemails = _service.RetrieveMultiple(
new FetchExpression(xmlAllemails)).Entities.First();
countAllemails = (int)resultAllemails
.GetAttributeValue<Microsoft.Xrm.Sdk.AliasedValue>("subject_count").Value;

}

.....

........

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: finding records programmatically only show 50k records

    Refer this:

    community.dynamics.com/.../155623

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans