You need to sign in to do that
Don't have an account?
Jeff Bryant 16
Cloning Records via Apex
Is there a simple way of mass cloning a record for testing purposes?
I was thinking of executing anonymous with something like...
Loan__c loanObj = [SELECT Id, Name, Status__c FROM Loan__c WHERE Name = 'L-1983549'];
List<Loan__c> loanList = new List<Loan__c>();
for(integer i = 0; i < 10; i++){
Loan__c loanObjClone = loanObj.clone(true);
loanObjClone.Name = 'loanObjClone ' + i;
loanList.add(loanObjClone);
}
insert loanList;
I was thinking of executing anonymous with something like...
Loan__c loanObj = [SELECT Id, Name, Status__c FROM Loan__c WHERE Name = 'L-1983549'];
List<Loan__c> loanList = new List<Loan__c>();
for(integer i = 0; i < 10; i++){
Loan__c loanObjClone = loanObj.clone(true);
loanObjClone.Name = 'loanObjClone ' + i;
loanList.add(loanObjClone);
}
insert loanList;
I recommend the solution listed here
Let me know if it helps