You need to sign in to do that
Don't have an account?
Number of SOQL queries: 101 out of 100 when run class
hello
I need assitance, when i run the class sow me the message "Number of SOQL queries: 101 out of 100". Anybody could help me? :(
public class PacoteVitron{
public static void ContatoTelefone() {
List<Lead> accList = [Select Id from lead];
PacoteVitron.Atendimento(accList);
}
public static void Atendimento(Lead[] Indicacao) {
List<Lead> LeadToUpdate = new List<Lead>();
for(Lead ll : Indicacao) {
AggregateResult[] tarefa=[
Select max(Createddate) ultima from task where Subject ='Ligação Call Center Fastcall' and whoid=:ll.id
group by whoid
];
if(tarefa.size() > 0){
if ((datetime)tarefa[0].get('ultima')!=null){
datetime dt=(datetime)tarefa[0].get('ultima');
ll.Data_da_ultima_ligacao__c=date.newinstance(dT.year(), dT.month(), dT.day());
LeadToUpdate.add(ll); }}
}
update LeadToUpdate;
}
}
Avoid SOQL query inside loop. Please try below code.
Let us know if it helps you.
Please try below code.It collects all lead ids first and then uses those in query.
Let us know if it helps you.