1

When I run this script successfully, I do not get my system.debug lines showing up in the console log. But I do get them if I remove the DML Update statement. Is there a good reference guide, that shows how the logs determine what gets logged?

list<Opportunity> opps = [SELECT id, Channel__c, Name, (SELECT id, role, isPrimary FROM Partners) FROM Opportunity Where Channel__c = '' AND isClosed = false];
system.debug(opps);
for(Opportunity o : opps){
    System.Debug('ZZZ : '+o.Name);
    if(o.Partners.isEmpty()) {
        o.Channel__c = 'Direct';
        System.Debug('     ZZZ Size : '+o.Partners.Size());
    } else {
        o.Channel__c = 'Partner';
        System.Debug('     ZZZ Size : '+o.Partners.Size());
    }
    for(Partner p : o.Partners){
        System.Debug('     ZZZ : '+p.role);
    }
}
update opps;
TheArchitecta
  • 1,426
  • 18
  • 47

1 Answers1

3

What is the size of your debug log?

If it is over 2MB SF truncates it and your debug statements can get discarded. Seems when you add in the DML a bunch of stuff occurs thus bloating the log.

To get the specific debug statements in that case change your debugs to:

system.debug(Logginglevel.ERROR,YOURDEBUGHERE);

And then change the logging levels to error

This is essentially a duplicate of: Need to get logfile smaller and several variations have been asked here many times

Eric
  • 54,152
  • 11
  • 100
  • 195