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
vijay kumar kvijay kumar k 

How to over ride clone button on vf page, and show the how many no of attempts clicks the clone button on existing standard object using custom field

Raj VakatiRaj Vakati
Use this controller and page 

Go and Override the clone button with this page .

 
Public Class CloneController
{
    
    private ApexPages.StandardController c;
    public String id { get; set; }
    // public Opportunity opp { get; set; }
    
    public CloneController(ApexPages.StandardController stdController) {
        c = stdController;
        //   this.opp = (Opportunity)stdController.getRecord();
        id = ApexPages.currentPage().getParameters().get('id');
        
        
    }
    public PageReference CloneRec(){
        Opportunity opp = [Select Id,Total_Clones__c from Opportunity where Id =:id Limit 1];
        if(opp.Total_Clones__c!=null){
            opp.Total_Clones__c = opp.Total_Clones__c+1 ;
        }else{
            opp.Total_Clones__c =0 ;
        }
        update opp ;
        return new PageReference('/'+opp.Id) ;
    }
    
}
 
<apex:page standardController="Opportunity" extensions="CloneController" action="{!CloneRec}"> 
   
</apex:page>

 
vijay kumar kvijay kumar k
thank you sir,
but it's throws error like shown in below ,what is that mean.
List has no rows for assignment to SObject
Error is in expression '{!CloneRec}' in component <apex:page> in page cdz: Class.CloneController.CloneRec: line 16, column 1
An unexpected error has occurred. Your development organization has been notified.
Raj VakatiRaj Vakati
Are you using same code ??? Can you please give me debug logs ?? 

Its working my for me .. the error might be existing codes