+ Start a Discussion
Vrushali Mali 4Vrushali Mali 4 

Giving error while creating class

"oppclass Compile Error: The method object <Constructor>(ApexPages.StandardController) is referenced by Visualforce Page (InvoicePDF) in salesforce.com."
Here is my class:

public class oppclass {
  public list<opportunity>opplist{get;set;}
   public ID opportunityid{get;set;}

    public oppclass() {
    
        opplist = new list<opportunity>();
        opplist = [select Name from opportunity];
        
    }

}
Best Answer chosen by Vrushali Mali 4
YogeshMoreYogeshMore
Hi Vrushali,

You are getting error because of there is visualforce page name as “InvoicePDF” in ypur org and you have given this class as a standard Controller for “InvoicePDF” visualforce page.
Try following code.
public class oppclass {
  public list<opportunity>opplist{get;set;}
   public ID opportunityid{get;set;}

    public oppclass(ApexPages.StandardController sc) {
    
        opplist = new list<opportunity>();
        opplist = [select Name from opportunity];
        
    }

}

Let us know if it helps you.

Regards,
Yogesh More
more.yogesh422@gmail.com || Skype:-yogesh.more44

All Answers

YogeshMoreYogeshMore
Hi Vrushali,

You are getting error because of there is visualforce page name as “InvoicePDF” in ypur org and you have given this class as a standard Controller for “InvoicePDF” visualforce page.
Try following code.
public class oppclass {
  public list<opportunity>opplist{get;set;}
   public ID opportunityid{get;set;}

    public oppclass(ApexPages.StandardController sc) {
    
        opplist = new list<opportunity>();
        opplist = [select Name from opportunity];
        
    }

}

Let us know if it helps you.

Regards,
Yogesh More
more.yogesh422@gmail.com || Skype:-yogesh.more44
This was selected as the best answer
Vrushali Mali 4Vrushali Mali 4
Thanks yogesh i solved this problem.
YogeshMoreYogeshMore
Great.
If above answer helps you to solve your problem then you can mark it as best answer so it useful for other.