function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deanna Aaron 11Deanna Aaron 11 

How to update the Primary Campaign on an Opportunity? Receiving error- dlrs_OpportunityTrigger: System.LimitException: dlrs:Too many query rows: 50001

Hi. I'm trying to update 2,358 opportunity records. They should be tied to our "2017 Year End Campaign". I'm using the dataloader:

I mapped the donation ID
I mapped the campaign ID (that is should be tied to)

Then, every record fails to update and I receive this error: 
dlrs_OpportunityTrigger: System.LimitException: dlrs:Too many query rows: 50001
Thank you for your help.
jigarshahjigarshah
Deanna,

Salesforce permits a maximum of 50,000 records to be retrieved using a Soql query which is a governor limit enforced by the Force.com Platform. The dlrs_OpportunityTrigger seems to be executing a Soql query that retrieves a result set having more than 50000 records which violates this governor limit and hence this error. Are you are using the Declarative Rollup Summary tool from Appexchange?

Simple things you can do to update the query so that only relevant records are retrieved are as follows.
  1. Use the Query Editor within Setup > Developer Console to investigate the exact result set of records that are being retrieved from the query.
  2. Include appropriate exclusion criteria within the Where clause of your Soql query along with AND and OR logical operators, to filter only applicable records.
  3. Add a Limit clause to your Soql query and set the max limit on the number of records to be retrieved which should not exceed more than 50000.
  4. If you are fetching records within a specifc date range apply an appropriate date filter and you can leverage a ton of ready to use datae functions mentioned at the following link - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_date_functions.htm.
Hope this helps.

Please mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.