Loading

npsp.TDTM_Contact: System.LimitException: Too many SOQL queries: 101

Publiceringsdatum: Mar 21, 2025
Beskrivning

In Salesforce Nonprofit Success Pack (NPSP), you may encounter an error like npsp.TDTM_Contact: System.LimitException: Too many SOQL queries: 101, while updating a Contact's address which is part of a Household Account.

This error typically occurs, if there are a large number of Contacts (for eg: more than 50) associated with the same Household Account, causing Salesforce to exceed its SOQL query limits when performing updates.

Why This Happens:

  • A Household Account is used to group Contacts who live in the same household.
  • If too many Contacts are grouped under a single Household Account, attempting to update a single Contact's information (e.g., their address) may result in Salesforce trying to update all Contacts in that Household at once.
  • This can lead to exceeding the system’s limit on the number of SOQL queries that can be executed during the update process.
Lösning

(i). Group the contacts to appropriate Household Account to ensure huge number of contacts are not associated under single Household Account and try to update the contact's address in NPSP.

(ii). If custom code is used, The error "Too many SOQL queries: 101" occurs when the number of SOQL queries executed in a single transaction exceeds the governor limit of 100. Here are some steps you can take to resolve this issue:

1. Review and Optimize SOQL Queries:
   - Ensure that your code is not making unnecessary SOQL queries within loops.
   - Use collections (like lists, sets, or maps) to store data and reduce the number of queries.
   - If you need to change the context, you can use @future annotation which will run the code asynchronously.
2. Disable Unnecessary Triggers:
   - If there are triggers that are not required for your operation, consider disabling them temporarily.
3. Batch Processing:
   - If you are processing a large number of records, consider using batch processing to handle them in smaller chunks.

Best practices to avoid exceeding the Governors Limit:

Since Apex runs on a multi-tenant platform, the Apex runtime engine strictly enforces limits to ensure code doesn't monopolize shared resources. 

For more detailed information, please refer to the following documentation: https://help.salesforce.com/s/articleView?id=000386220&type=1

Knowledge-artikelnummer

004575675

 
Laddar
Salesforce Help | Article