I want to be able to create a renewal opportunity on accounts, and would like to copy the fields over from the most recent opportunity against that account. What would be the best practise to do that? Is there a best practise to create renewal policies? Tia.


We have done this many times with a custom button placed on the opportunity layout. If a user clicks it reroutes to a visualforce page which has the only purpose of automatically invoking a clone action function in a custom controller. As target we used the URL of the page and the source opp Id as parameter


In the controller action function you can query the existing opp and use the SObject.clone() method. Then you most likely will make some adjustments to the cloned opp before insert.

Necessary adjustments might be e. g. close date, type, custom fields and custom relationships according to your datamodel.

Another aspect you have to consider are child objects like OpportunityLineItem, OpptunityContactRole, etc. - if you use them you might also want to clone them, too.

If you don't like code, there is a standard clone button which can be placed on the layout but only performs a 1:1 copy.


You could do this using Flow with Flow Triggers (to fully automated), so you would not need to create any Apex.

To start with you can run the flow from a custom button on the Opportunity.

High level flow design

  1. Create input variable - current opportunity I'd
  2. Fast lookup Opportunity & OppLineItems
  3. Create Record Opportunity setting values
  4. Loop OppLineItems collection created in step 2 assigning the values include the newly created Opportunity Id to link the lines
    1. Fast create OppLineItems

Obviously vary rough and quick, but worth exploring.

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.