Each Opportunity in our Salesforce system may have zero or more related Opportunity Items which are custom objects. The relationship and use of Opportunity and Opportunity Items is like Orders and Order Items in an e-commerce system.
When an Opportunity is cloned by clicking the Clone button on the Opportunity Details page, these associated objects are not cloned.
I would like to intercept the cloning process to manually clone the Opportunity Items as well.
This must be a fairly common scenario, and I thought of implementing a trigger however, I don't know how to distinguish between a New Opportunity and a Cloned Opportunity, I've presumed that it's just a new Opportunity to the trigger.
How might I clone an Opportunity plus the related Opportunity Items. I should also add the further complication that the cloned Opportunity Items have a custom field named IsEditable__c that must be set to false on the cloned Opportunity Items.