We are using a trigger framework by Kevin O'Hara and I have a basic question about it. Why when I use Trigger.New inside one of the methods I have to cast it to a List of cases in order to use it?
public class CaseTriggerHandler extends TriggerHandler {
public CaseTriggerHandler() {
this.setMaxLoopCount(35);
}
private static Boolean isMethod1 = false;
protected override void beforeInsert(){
if (!isMethod1) {
method1(Trigger.new);
isMethod1 = true;
}
}
private void method1() {
for(Case c: (List<Case>)Trigger.New) {} //<------------------
}
}
If I write for(Case c: Trigger.New)
then I get this error:
Operation: Compiling: C:\Users\Dante\proj\src\classes\CaseTriggerHandler.cls Timestamp: Sun, 27 Aug 2017 18:29:00 Result: [OPERATION FAILED]: classes/CaseTriggerHandler.cls: Invalid loop variable type expected SObject was Case (Line: 1324, Column: 9)
Can someone explain?