You need to sign in to do that
Don't have an account?

Help resolve Too many SOQL queries error
Hello,
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 : Trigger.new){ if (a.ShippingCountry == NULL){ a.ShippingCountry = 'NONE'; } if (a.ShippingCountry <> NULL){ CountryNames.add((a.ShippingCountry.toUpperCase())); }} 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 : Trigger.new) 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.
Thanks,
Samba
Check in the debug logs for more error on other triggers you might be triggering///