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
margotwmargotw 

How to check if the Opportunity records are cloned

I tried following the steps in Knowledge Article Number: 000181281 on how to check if an Opportunity record is cloned, but I'm getting an error message in the Apex Class.

Error: Compile Error: Method return types clash: clone() at line 8 column 22

Line 8 is:  public PageReference clone(){

Any advice on how to fix this?  TIA.

Here's the link to the Knowledge Article:  https://help.salesforce.com/HTViewSolution?id=000181281&language=en_US
Vamsi KrishnaVamsi Krishna
can you check if your clone method returning a pagereference object properly ?

if you can post your complete clone method code, we can see where its failing..
margotwmargotw
Thanks, Vamsi.  Here's the code I am using:

===============================VF page ==================================

<apex:page standardController="Opportunity" extensions="cloneopportunity" action="{!clone}">
</apex:page>

===============================Apex class===============================

public class cloneopportunity {
public opportunity o = new opportunity();
public opportunity c = new opportunity();
public cloneopportunity(ApexPages.StandardController controller) {
o = (Opportunity)controller.getRecord();

}
public PageReference clone(){
o = [select id, name, stagename, closedate, Clone__c from opportunity where id=: o.id];
c.name=o.name;
c.stagename=o.stagename;
c.Clone__c=true;
c.closedate=o.closedate;
insert c;
//PageReference pr = new PageReference('/'+c.id);
PageReference pr = new ApexPages.StandardController(c).view();
system.debug('>>>>>>>>'+pr); return pr;
}
}