I predicted we would run into recursive triggers with a project that we are currently working on. To pre-empt this, I searched for solutions and came across this:
I modified the code to the following:
public class checkRecursive {
public static integer runCount {
get {
return runCount == null ? 0 : runCount++;
}
}
}
The code provided by Salesforce does infact prevent the recursive triggers. My code does not. I'm curious to know the reasoning behind it. Primarilly, since my code is short hand for the following:
public class checkRecursive {
public static integer runCount;
public static integer getRunCount() {
if (runCount == null) {
return 0;
} else {
return runCount++;
}
}
}
Which to me, doesn't look a whole lot different from what is provided by salesforce.