8

I've created an Apex trigger on CustomObject_A__c, it is working fine when I clone a record in Classic Aloha interface, but the trigger does not return True for isClone() sObject function call, when I try to clone record in Lightning Experience.

trigger CustomObjectTrigger on CustomObject_A__c (before insert, before update)
{
    if (trigger.isBefore)
    {
        for (CustomObject_A__c a : trigger.new) {
            system.debug('@@ (isCloned): '+a.isClone());
            system.debug('@@ (clonedFrom): '+a.getCloneSourceId());
        }
    }
}

Debug output in Lightning Experience:

10:01:02.0 (26981116)|USER_DEBUG|[11]|DEBUG|@@ (isCloned): false
10:01:02.0 (27065138)|USER_DEBUG|[12]|DEBUG|@@ (clonedFrom): null

Debug output in Classic Aloha:

10:06:54.0 (7464346)|USER_DEBUG|[11]|DEBUG|@@ (isCloned): true
10:06:54.0 (7542087)|USER_DEBUG|[12]|DEBUG|@@ (clonedFrom): a0b9000000FxSYMAA3

As you can see, the bug validates my cause that trigger was able to identify properly a Cloned record in Classic interface but not in Lightning Experience. Is this a Known Bug/Issue?

I've found that this isClone() function was introduced in Winter '16 - isClone function added to apex code in Release Notes also, when we scroll down to Bottom of these release notes, we can find this Idea mentioned as Delivered - Idea - Detect isClone() within Trigger

  • Can someone from Salesforce confirm this as a Bug? or is it as Designed? Has anyone found this same behavior occurring for them as well? And what is the workaround other than Clone button override with Visualforce? – VarunC Nov 9 '16 at 12:54
  • Is there anyone who can confirm me this behavior? Or if this is a bug, then provide some confirmation with a Known Issue link? – VarunC Nov 15 '16 at 19:13
1

This is a known issue, unfortunately.

Lightning: ISCLONE() does not work the same as ISNEW() in regards to Workflow Rules

Subscribe to the issue to be notified when a fix is available.

  • 1
    the know issue doesn't seem to mention much in the way of isClone() behavior, how do you know it's related and the fix will address the OP's issue? Did support say it's the same issue? – Ralph Callaway Mar 6 '18 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.