// create one class and create another class for recursive and fetch it to main class
public class CloneRecordOfAccount { public static void Accountrecord(list <account> lcclist){ if (Recursive.runonce()){ list <account> newlist = new list <account>(); newlist = lcclist.deepclone(); insert newlist; } } }
public class Recursive { Private static boolean run = true; public static boolean runonce(){ if (run){ run=false; return true; } else{ return run; } } }
Please refer below link which has similar question .
https://developer.salesforce.com/forums/?id=9062I000000gA9lQAE
Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.
Thanks and Regards
public class CloneRecordOfAccount {
public static void Accountrecord(list <account> lcclist){
if (Recursive.runonce()){
list <account> newlist = new list <account>();
newlist = lcclist.deepclone();
insert newlist;
}
}
}
public class Recursive {
Private static boolean run = true;
public static boolean runonce(){
if (run){
run=false;
return true;
}
else{
return run;
}
}
}