+ Start a Discussion
Anil SavaliyaAnil Savaliya 

Create Clone button on Custom visualforce for Custom Object which assiged to Tab

I have custom object Target.we are created custom visualforce page and assigned to Target Tab.We used custom visualfoce for targert because we have lot of  validation during record save and page layout implemention according to product selected.

Example : Assiged Visaulforce CreateTarget to target tab (/apex/CreateTarget).Now business want to create clone button on created visualforcepage (CreateTarget).Is there any API for Clone or Idea? 

Please help on create custom clone button on visualforce page?
Bryn JonesBryn Jones
Best and easiest way is to copy the link from the address bar after clicking CLONE button from another OEM salesforce page, and then modifiyng it to work it your application.

Please mark as answer if this helped and work.

Hey Andy,
You can use URL hacking for this like, Crate a Command Button named Clone on VF page as follows:

<apex:pageBlockButtons id="editBtn">
            <apex:commandButton id="cloneBtn" value="Clone" action="{!cloneCase}"  />

On controller write the following code snippet:
public class CloneCaseController{
Id recId {get; set;}

public Pagereference cloneCase() {

  recId = ApexPages.currentPage().getParameters().get('id');
  if(recId == null) return null;

  Pagereference targetClonePg = Page.<Your Page Name>;
   targetClonePg.getParameters().put('clone', '1');
   targetClonePg.getParameters().put('id', recId);
   targetClonePg.getParameters().put('retURL', recId);
   return targetClonePg;
Anil SavaliyaAnil Savaliya
Hi,I have record in visalforce page and I have to clone it,and open record in Visualforce page.
Amit @ it's work for standard page.
Joseph BauerJoseph Bauer
I'm having the same issue. If I clone it in a visual force page it is actually editing the object I want to clone and not cloning it.
Hi DevADS,

I am working on cloning function too. Your code works for cloning. However, how to save the current record at the same time? The code copies everything I type in, but not saving the current record.