Account acc = new account(name='Rahul');
insert acc;
account acc1 = acc.clone();
insert acc1;
Account accc = [select id from account where id =: acc1.id];
system.debug(accc.isClone());//Supposed to display true
But it is being displayed as False. It is supposed to show true as acc1(accc) is a clone of acc.
isClone()
method will only return true for SObject that are clones in memory. So becauseaccc
is an actual record, loaded from the database,isClone()
will return false. If you need this functionality, you will have to keep track of the fact that a record is cloned using a custom field and, for instance, a workflow (see help.salesforce.com/…)