Activity Forums Salesforce® Discussions How to handle "Too many soql queries:101" problem in Salesforce? Reply To: How to handle "Too many soql queries:101" problem in Salesforce?

  • Rahul

    Member
    February 10, 2018 at 5:46 am

    Hi,
    Thanks for reply,  but i am not calling to query in loop .
    Here is my code:

    listCaseTCR = [SELECT id,RV_Consignment_Status__c ,CN_Number__c,Case_Category__c,Issue_Type__c,Sub_Title__c
    FROM Case WHERE Issue_Type__c =:'Tech - CR' AND Sub_Title__c IN:subtitle AND CN_Number__c!='NULL' AND Status!='Closed' AND RV_Is_Parent__c=:FALSE];
    if(!listCaseTCR.isEmpty()){
    //for(Case cr : listCaseTCR)
    total = listCaseTCR.size();
    system.debug('total cases of Tech - CR are :'+total);

    for(i=0;i<total;i++)
    {
    cnumber=listCaseTCR[i].CN_Number__c;
    if(cnumber!=Null && cnumber!='')
    trackconsignment(cnumber);
    }
    }

     

    now problem start from here that when i am calling trackconsignment(cnumber); method then this is using 32 soql queries to closed a case and i have a  lot of cases in list listCaseTCR  so it's firing 101 error.
    how to handle it?

    regards,

    Rahul Kumar