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
Mitchell McLaughlin 1Mitchell McLaughlin 1 

Customized Opportunity Clone

Hi - 

I'm looking for a solution to clone an opportunity in Salesforce.
I'm assuming i will need a customized clone button, which i already created and will need to tie some APEX code to it.
The difference between the standard clone and what i need to do is that i want to copy all of the fields to the new opportunity, from the old one, and also an opportunity holds "opportunity segments" which there can be multiple.
I also want to recreate these opportunity segments and tie them to my new opportunity, just like the old opportunity... but an exact copy.

My company is very against Visual Force too. Is there anyway to just add the action onto the custom button?

Any advice helps, thank you so much!

SalesFORCE_enFORCErSalesFORCE_enFORCEr
Check this
https://developer.salesforce.com/forums/?id=906F0000000AxReIAK
James LoghryJames Loghry
Even though your company is against it, Visualforce still is a valid solution.  Another valid solution is to utilize Flow.  The flow would take an Id field as an input variable, and then query for all the related information including segments.  Loop through, and create the new opportunity and any new segments before you use a record create or a fast create element to insert the new records.

Once the flow is tested and activated, then you could call it from a URL button like so:
/flow/Custom_Opportunity_Clone_Flow?opportunityid={!Opportunity.Id}

 
Rakesh51Rakesh51
One i found here https://automationchampion.com/2014/04/23/deep-clone-through-visual-workflow-flow/
Mitchell McLaughlin 1Mitchell McLaughlin 1
I appreciate the suggestion with the visual force page, but it does not play nicely on Mobile!