MyRapidi
MyRapidi

Search our Wiki

E2120 Too many query rows

When "Too many query rows: 50001" and "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" appear together, it means that an insert or update operation is failing due to a trigger or automation exceeding the SOQL query row limit (50,000 records).

E2120 - ECE_SForceUpdateInsert: We got an error back from SalesForce when trying to update or insert data in SalesForce.
Error returned from SFDC on upsert: [message: SalesOrderLineTrigger: System.LimitException: Too many query rows: 50001 , statusCode: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY ] , Record does not exist in SFDC, Data sent to SFDC: sObjects: [type: SalesLine__c , Unique_Key__c: 0#SO-013018#40000 , Name: 00040000 , No__c: LT , Description__c: Production only.

What is happening in Salesforce?

A record (or multiple records) is being inserted or updated.

  • This is usually through an API call in Salesforce.

A trigger, Process Builder, or Flow runs as part of this insert/update.

  • The automation contains SOQL queries.

The SOQL query inside the automation retrieves more than 50,000 records.

  • Salesforce enforces a governor limit that prevents a single transaction from querying more than 50,000 rows.

Salesforce throws "Too many query rows: 50001".

  • Because this happens inside a trigger or automation, the insert/update cannot proceed.

The error "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" is thrown.

  • This tells you that the failure happened due to a trigger, Process Builder, or Flow that was supposed to run during the record update.

Solution:

  • Add Selective Filtering to SOQL : Instead of querying all records, only query the needed ones.This ensures only the required records are queried, avoiding the 50,000 row limit.