I'm trying to figure out how to create an opportunity page that will have the exact same fields as an old opportunity page except that it will have a different Id. That's it, only the ID should be different, the rest should all be the same. All the fields and their values that were in the old Opportunity should carry over to the new Opportunity. What's the proper method of doing this?

This isn't for a trigger, I'm creating a custom button in Salesforce that requires this as one of its functionalities.

Basically this is how that button should work. The button will be on an entitlement page.

  1. Put the button in Entitlement Page
  2. Click on the QuoteCalculator button (the button that I have to create)
  3. Takes you to a visualforce page where you can select Assets for which you can create a Quote.

  4. After selecting these assets, it will take you to a brand new Opportunity page. This new opportunity page has the same fields and values as the Old Opportunity page which is linked to the Entitlement page from the beginning. Inside the opportunity page is a brand new Quote based on the Assets that were picked.

  • 1
    There is a standard Clone button you can add to an opportunity page layout. Doesn't that do what you want? – Daniel Hoechst Jun 20 '13 at 20:20
  • appending /e?clone=1 to the URL of the Opportunity you want to clone will open a cloned Opportunity in edit mode. – techtrekker Jun 28 '13 at 11:11

That blog post is great and may help with your needs.

I just want to mention new app on AppExchange iClone which allows you to clone any record with any related list. For eg opportunity with activities and line items.

You can provide default field values too. Here is the URL: https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B39tWEAR

Hope it helps someone.


I've written a JSON serialisation utility that can be used with one line of code to clone and requires only the Id of the record to be cloned. It will automatically seak out relationships and clone those, though the depth and paths it follows can be configured if needed, here is the most basic example.

Set<ID> clonedMasterIds =
 SObjectDataLoader.deserialize( SObjectDataLoader.serialize(masterIdsToDeepClone) );

You can read more about it on this answer as well. Deep Clone (Parent -> Child -> Grand Child).

The test code used in the class actually clones an Opportunity and related records. If desired I can work out this answer a little bit further into a small StandardController extension that can be tied via a VF page to a Custom Button on Opportunity.


Take a look at this blog post on writing a clone for all fields as well as related records: http://christopheralunlewis.blogspot.co.uk/2012/04/clone-plus-clone-salesforce-objects.html

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.