function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lawrence-AccentureLawrence-Accenture 

isClone() in Trigger idea closed, but where is the functionality?

This idea: https://success.salesforce.com/ideaView?id=08730000000BrGFAA0 -- "isClone() within trigger" -- was posted seven years ago and was recently closed as being delivered in Winter '16. Does anyone know how it was delivered? Does anyone know how to do what the asker was asking for?

I'm aware there is a new sObject.isClone() method that was delivered in Winter '16, however that doesn't appear to work with records cloned in the UI, just records cloned within Apex using the sObject.clone() method. Same thing for the sObject.getCloneSourceId() method -- works if cloned via Apex, but not within the UI even though the documentation explicitly states "You can use it for objects cloned through the Salesforce user interface."

Or am I missing something? My trigger is using the latest Apex version (37.0). Has anyone been able to get this to work for records cloned in the UI?

Thanks,

-L
@Karanraj@Karanraj
You can use objectinstance.isclone in apex trigger to identify
trigger clonetest on Account (before insert) {
    for (Account acc : Trigger.new) {
        if (acc.isClone()) {
            //write your logic
        }
    }
}

 
Lawrence-AccentureLawrence-Accenture
Thanks Karanrajs, I just confirmed that it does work for Account and for Contact, but it doesn't seem to work for Opp. I just tested in my Dev Org, so this seems to be the case for my Dev Org and at least one Sandbox.

Can anyone confirm whether or not this is working for Opps for you?
Lawrence-AccentureLawrence-Accenture
FYI... this is the trigger code I'm using for Opps to test this:
 
trigger TestIsClonedOpp on Opportunity (before insert) {
    for (Opportunity opp: Trigger.new) {
        if (opp.isClone()) {
            System.debug(LoggingLevel.ERROR, '====> isClone: true');
        }
        else {
            System.debug(LoggingLevel.ERROR, '====> isClone: false');
        }
    }
}

 
Lawrence-AccentureLawrence-Accenture
I've done additional testing and confirmed that isClone() appears to work for Campaigns, Cases and for Custom Objects as well. Just Opp seems to be the exception.
Lawrence CoffinLawrence Coffin
This is now a Known Issue: https://success.salesforce.com/issues_view?id=a1p3A0000001BbRQAU