+ Start a Discussion
Anil SavaliyaAnil Savaliya 

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

Hi,
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?
DevADSDevADS
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}"  />
  </apex:pageBlockButtons>

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;
}
}
Nav_GupNav_Gup
Hey DevADS,

Thanks for this code, actually at last I want to save this clone page with some name like <clonePage>, so what I use for this ?

Thanks in advance...