You need to sign in to do that
Don't have an account?
nilesh walke
trigger CloneARecord on Account (After insert) { if(cloneHandler.runOnce()){
list<Account>Accounts = new list<Account>();
for(Account record: trigger.new){ Accounts.add(record.clone(false,false,false,false));
}
if(Accounts.size()>0){
INSERT Accounts;
} }
}
[05-05 12:45 pm] Nilesh Walke
public class cloneHandler {
public static boolean run= true;
public static boolean runOnce(){
if(run){ run=false; return true;
}
else{ return run;
} } }
test class for it
nilesh walke Write a Trigger on Account which will create the clone record for test class
trigger CloneARecord on Account (After insert) { if(cloneHandler.runOnce()){
list<Account>Accounts = new list<Account>();
for(Account record: trigger.new){ Accounts.add(record.clone(false,false,false,false));
}
if(Accounts.size()>0){
INSERT Accounts;
} }
}
[05-05 12:45 pm] Nilesh Walke
public class cloneHandler {
public static boolean run= true;
public static boolean runOnce(){
if(run){ run=false; return true;
}
else{ return run;
} } }
test class for it
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!