You need to sign in to do that
Don't have an account?
satyam
Too Many SOQL Problem-Urgent Help
Hi Everyone,
We have a requirement where we need to compare current Client support record with all the old client support record and that needs to be done before saving the record.
We need to compare near about 12 fields for every record which we are selecting during mass operation (can select 100 record for mass operation),but we are not having any field which can used as a key without saving the record.
Hi,
How are you calling this class (i.e. off a button or a trigger)? Also, what does your other original class look like (the one that gave you the SOQL error)? You might want to try a future method here. But even with that you might want to limit the records that call this operation.
Thanks for Reply!!
We are calling this method from another class method and passing a list of record to this method .
so my problem is that i want to run this below method for all the record passed through list .
So now i think you will understand my issue.
Thanks
Hi ,
Below is the code:
public static Map<Client_support__c,List<String>> checkDuplicateClientSupportforMassChangeone(List<Client_support__c> PSList){
List<String> duplicatesPS= new List<String>();
List<Client_support__c> OldPS=new List<Client_support__c>();
oldPS =[select id,status__c,distributor_PRofile__c,Material_Selling__c,Material_Buying__c from Client_support__c where status__c='Approved' or status__c='Awaiting distributor Approval' or status__c='Awaiting Approval'];
List <Client_support__c>l1 = new List<Client_support__c>();
Map<Client_support__c,List<duplicate>> mapPS = new Map<Client_support__c,List<duplicate>>();
List <String> l2=new List<String>();
for(Client_support__c ps:PSList){
for(Client_support__c ps1:oldPS){
if(ps.distributor_PRofile__c!=null){
if(ps.distributor_PRofile__c == ps1.distributor_PRofile__c){
l1.add(ps1);
}
}
if(ps.Material_Selling__c!=null){
for(Client_support__c li : L1){
if(ps.Material_Selling__c == ps1.Material_Selling__c){
//l1.add(li);
l2.add(li.aggrement_number__c);
}
}
}
}
mapPS.put(ps1 ,l2);
}
This is the whole code but now i am getting Too many code statements: 200001
Red line code is giving error i think its because of for loop inside loop but not know how to do this in single for loop.
Thanks for Help :)))
try this let me know if it throws any error// Can you explain what exactly you are trying in the highlighted code?