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

Help resolve Too many SOQL queries error



I'm getting error: Too many SOQL queries: 101 Trigger.UpdateTableLink: line 16, column 1. Line 16 in my code is


 List<Country_Codes__C> ICC = [Select id, Country_Name__c from Country_codes__C Where Country_Name__c in :CountryNames ];  


Below is my full code. Please advise on how to fix with specific code examples.


trigger UpdateTableLink on Account (before insert, before update) {
   Set<String> CountryNames = new Set<String>();

    for (Account a :{
      if (a.ShippingCountry == NULL){
      a.ShippingCountry = 'NONE';   

    if (a.ShippingCountry <> NULL){

    List<Country_Codes__C> CC = [Select id, Country_Name__c from Country_codes__C Where Country_Name__c in :CountryNames ];  

    Map <String, ID> map1 = new Map<String, ID>();
    for (Country_Codes__c countryRecord: CC) {
        map1.put(countryRecord.Country_Name__c, countryRecord.Id);

    for (Account a :
 if (a.ShippingCountry <> NULL){
        a.CountryCodesLink__c = map1.get(a.ShippingCountry.toUppercase());

      }  }



Look like problem is not with the trigger, are u using any apex to insert or update Accounts ?


Please check whether this account object has some workflows or the other triggers.




Team WorksTeam Works

Check in the debug logs for more error on other triggers you might be triggering///