-1

I can't understand why I am not getting my debugs in here--

my code is

for(AGR_Agreement__c agr:newAgr){
    for(Account acc:agr.Accounts__r){
    system.debug('MVK '+agr.AMS_Agreement__c);
        system.debug('MVK '+agr.Agreement_Status__c);
        system.debug('MVK '+agr.Sub_Service__c);
        system.debug('MVK '+acc.Account_Record_Type__c);

        if(agr.AMS_Agreement__c == true && agr.Agreement_Status__c.equals(deactivatedStatus) && !acc.Account_Record_Type__c.equals(recTypeInternational) 
            && !acc.Account_Record_Type__c.equals(recTypeCandidatePool)){
            acc.Central_purchasing__c = '';
            lstAccounts.add(acc);   
        }                   

        else if(agr.AMS_Agreement__c == true && agr.Agreement_Status__c.equals(applicableStatus) && agr.Sub_Service__c.equals(subServicePriceAgreeement) && !acc.Account_Record_Type__c.equals(recTypeInternational) 
            && !acc.Account_Record_Type__c.equals(recTypeCandidatePool)){
            acc.Central_purchasing__c = agr.Name;
            lstAccounts.add(acc);
        }
        else if(agr.AMS_Agreement__c == false && !agr.Agreement_Status__c.equals(applicableStatus)  && !agr.Sub_Service__c.equals(subServicePriceAgreeement) && !acc.Account_Record_Type__c.equals(recTypeInternational) 
            && !acc.Account_Record_Type__c.equals(recTypeCandidatePool)){
            acc.Central_purchasing__c = '';
            lstAccounts.add(acc);
        }
    }
}
//Since in test classes we are inserting accounts multiple times (parent and child) we cant bypass this trigger as it will make the second account insert not working
if(!Test.isRunningTest()){
    PAD.addTriggerBypass(PAD.TH_ACC_AccountTriggerHandler); //Remove lag by avoiding triggers
}
Database.update(lstAccounts, true);

Debug logs--

|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413210330)|METHOD_EXIT|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413214858)|METHOD_ENTRY|[1407]||Database.QueryLocatorIterator.next() 11:17:58.357 (3413264259)|METHOD_EXIT|[1407]||Database.QueryLocatorIterator.next() 11:17:58.357 (3413548087)|METHOD_ENTRY|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413561139)|METHOD_EXIT|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413692191)|METHOD_ENTRY|[1432]||System.Test.isRunningTest() 11:17:58.357 (3413741766)|METHOD_EXIT|[1432]||System.Test.isRunningTest() 11:17:58.357 (3415607798)|METHOD_ENTRY|[1]|01pb0000001hhZp|PAD.PAD() 11:17:58.357 (3418611641)|METHOD_ENTRY|[152]||System.UserInfo.getName() 11:17:58.357 (3418682655)|METHOD_EXIT|[152]||System.UserInfo.getName() 11:17:58.357 (3418900071)|METHOD_ENTRY|[156]||System.UserInfo.getUserId() 11:17:58.357 (3418934254)|METHOD_EXIT|[156]||System.UserInfo.getUserId() 11:17:58.357 (3420734126)|SOQL_EXECUTE_BEGIN|[153]|Aggregations:0|SELECT UserRole.Name, Profile.Name, UserPreferencesApexPagesDeveloperMode, Bypass_Trigger__c, PAD_BypassTrigger__c, LanguageLocaleKey FROM User WHERE Id = :tmpVar1 LIMIT 1 11:17:58.357 (3428772309)|SOQL_EXECUTE_END|[153]|Rows:1 11:17:58.357 (3429806271)|METHOD_EXIT|[1]|PAD 11:17:58.357 (3429821586)|METHOD_ENTRY|[1433]|01pb0000001hhZp|PAD.addTriggerBypass(String) 11:17:58.357 (3429902682)|METHOD_EXIT|[1433]|01pb0000001hhZp|PAD.addTriggerBypass(String) 11:17:58.357 (3429951734)|DML_BEGIN|[1435]|Op:Update|Type:Account|Rows:2715

so my system debugs are not printing..

can you please help.

1

If I'm reading this right, all the logs are telling us is that when you reach this section of code:

for(AGR_Agreement__c agr:newAgr){
    for(Account acc:agr.Accounts__r){

newAgr contains one AGR_Agreement__c and its Accounts__r related list is empty. That's what these lines are telling us

|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413210330)|METHOD_EXIT|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413214858)|METHOD_ENTRY|[1407]||Database.QueryLocatorIterator.next() 11:17:58.357 (3413264259)|METHOD_EXIT|[1407]||Database.QueryLocatorIterator.next() 11:17:58.357 (3413548087)|METHOD_ENTRY|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413561139)|METHOD_EXIT|[1407]||Database.QueryLocatorIterator.hasNext() 11:17:58.357 (3413692191)|METHOD_ENTRY|

next() gets called once for the outer loop and zero times for the inner loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.