I have spent hours on it but haven't been able to figure out anything. The idea is simple:
- User clicks on standard Opportunity clone button.
- User selects either 'Clone without products' or 'Clone with Products'
On the cloned record, the stage is set to Identified (first one) and certain custom fields are cleared out (doesn't matter if it's with or w/o products). I started off with a simple trigger like this:
trigger OpportunityClone on Opportunity (before insert) { for (Opportunity o : Trigger.new) { if (o.isClone()) { o.StageName = 'Identification'; o.IsCloned__c = true; o.Roll_Out_Plan__c = NULL; o.Rollout_Duration__c = NULL; o.Roll_Out_Start__c = NULL; o.External_Opportunity_ID__c = NULL; } }}
But for some weird reason, it works perfectly for the 'Clone With Products' button action but doesn't do anything for 'Clone Without Products' action.
It seems like the isClone() isn't being detected at all when doing the latter.
Is there a way to fix the above or an alternative better way? Any help is much appreciated. I have pulled my hair enough on this.
isClone()
returnsfalse
withclone without products
just tested.