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
Jenny Chen 9Jenny Chen 9 

How to know in Apex trigger that action from "clone" or "Edit" opportunity button

I need to do something in opportunity clone, but not for opportunity edit. Is there a way to differentiate this in Apex trigger ? It will come from "clone" or "Edit" opportunity button and in Apex trigger for update. 

Thanks for your help. 
arpit vijayvergiyaarpit vijayvergiya
Hi Jenny,

You can use isClone() method to identify that record is being created using clone or not.
Here is the example of code.
trigger OpportunityTrigger on Opportunity (before insert) {
    for (Opportunity objOpp : {
        if (objOpp.isClone()) {
            //write your logic
Let me know if you any suggestion or issue.

Arpit Vijayvergiya