Well, they say that no platform is perfect, and Salesforce definitely has its share of quirks. Here's one more. I have the following structure:

Trigger on Lead:

//some random code
  //some code
//some random code

in the myClass Class:

public static boolean myBooleanVar = FALSE;

As you all would know, this is the standard way to avoid recursion in triggers.

Scenario 1: If I upload 100 records (say) and get at least 1 error, the 'system.debug' statement is printing 'TRUE'. This doesn't make sense as I am explicitly initialising the boolean to 'FALSE' in 'myClass'.

Scenario 2: If I upload 100 records and if all are successful, the 'system.debug' statement is printing 'FALSE'. (as desired)

Any ideas on what the issue might be? Thanks!

  • Have you anywhere changed the variable myBooleanVar to true. AS its not possible system.debug print it true. Share your trigger code – SFOnlineSolutions Sep 26 '14 at 8:19
  • Hi @SFOnlineSolutions, I have written this custom setter: public static boolean myBooleanVar{ get; set{ system.debug('myBooleanVar setter called with value: ' + value); myBooleanVar = value; } } However, the statement 'myBooleanVar setter called with value' is not to be found anywhere in the Debug Logs. – Kanav Khurana Sep 26 '14 at 10:56

Your code with line "myBooleanVar = value;" is creating problem for you. If Salesforce debug log is too large then it can skip some part and don't show in debug log. Try to replce the line "myBooleanVar = value;" with "myBooleanVar = False;" and perform the DML to run the trigger again. Now check the debug log to find out True and if you don't it then am correct, So findout from where that variable is set to True.

  • Thanks @SFOnlineSolutions, i'll have a go at it and let u know. – Kanav Khurana Sep 29 '14 at 5:05
  • You were right. I found where the variable was getting set to TRUE. The logs weren't showing it, which is strange, since we usually get the message "XYZ bytes.. log skipped" if the logs are skipped. But anyhow, problem solved! thanks. :) – Kanav Khurana Sep 29 '14 at 7:19

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.