I wrote a trigger for creating Child cases from a case, but it is going in infinite loop. as every child case that is created from parent Case calling the apex trigger.
trigger DemoTrigger on Case (after insert) {
List<Case> childCases = new List<Case>();
System.debug('Size' + Trigger.new);
for(Case parent: Trigger.new){
childCases.add( new Case(ParentId = parent.id, Subject = parent.Subject));
}
insert childCases;
}
I want to call a Apex Trigger only 3 time to create 3 child cases. how to put limit on number of calls? is there any way to do this?
CTRL + K
or the{}
button. I did so for you in this case.