Solution: Use the isClone() to determine if the current record is cloned from something or not
Example: In the below piece of code,initially I created one account and then created another account by cloning the first account.
Run the code from the developer console.
Account objAccount = new Account(Name = 'Test Account Clone');
insert objAccount;
system.debug('Account Record Id :'+objAccount.Id);
system.debug('Is this account Cloned? :'+objAccount.isClone());
Account objAccount2 = objAccount.clone();
system.debug('Is this account Cloned? :'+objAccount2.isClone());
insert objAccount2;
system.debug('Account Record Id :'+objAccount2.Id);
system.debug('Is this account Cloned? :'+objAccount2.isClone());
Output:
No comments:
Post a Comment