I am trying to compile an Apex Class that works with a Visualforce page and upon attempting to save, keep receiving the error: Error: Compile Error: The method System.PageReference resetFilter() is referenced by Visualforce Page (NitishContactListViewVFPage) in salesforce.com. Remove the usage and try again.

I've tried the solution listed in this other question: "Error: The method is referenced by Visualforce Page in salesforce.com. Remove the usage and try again" Error: The method is referenced by Visualforce Page in salesforce.com. Remove the usage and try again but was still unable to save my Apex Class. I've tried logging out and back in, refreshing the browser, everything, and it still won't allow the removed code to save.

Can anyone assist in helping find out why I can't save this class?

Apex Class: NitishContactListViewClass

public class NitishContactListViewClass {

   //public List<SelectOption> listViewNames=[SELECT Name,SobjectType FROM ListView WHERE SobjectType = 'Contact' order by Name DESC];

   public List<SelectOption> listViewNames{get; set;}
   public String conFilterName{get; set;}

   public NitishContactListViewClass(ApexPages.StandardController controller) {ApexPages.StandardSetController mySetCon = new ApexPages.StandardSetController([SELECT Id FROM Contact LIMIT 1]);

   List<Id> listViewIds = new List<ID>();

   for(SelectOption so :mySetCon.getListViewOptions()){

   for(ListView lv :[SELECT Id, Name FROM ListView WHERE ID IN :listViewIds ORDER BY Name ASC]){
       listViewNames.add(new SelectOption(lv.Id, lv.Name));

   //public NitishContactListViewClass(ApexPages.StandardController controller){
        String q = 'SELECT Name FROM Contact LIMIT 1'; //Any object whose list view you are trying to retrieve.
        ApexPages.StandardSetController ACC = new ApexPages.StandardSetController(Database.getQueryLocator(q));
        List<SelectOption> ListViews = ACC.getListViewOptions();
        listViewNames = new List<SelectOption>();
        for(SelectOption w : ListViews ){
            listViewNames.add(new SelectOption(w.getLabel(), w.getLabel()));
      //listViewNames= [SELECT Name,SobjectType FROM ListView WHERE SobjectType = 'Contact' order by Name DESC];

    //public PageReference resetFilter() //Dummy function
        //return null;

Visualforce Page: NitishContactListViewVFPage

<apex:page standardController="Contact" extensions="NitishContactListViewClass">

<apex:pageBlock > <!-- formatting for the page -->

<apex:form >

<apex:actionStatus id="ajaxStatus" startText="Loading..."  stopText=""/>

    <apex:selectList value="{!conFilterName}" size="1" id="filterMenu">
        <apex:selectOptions value="{!listViewNames}" />
        <apex:actionSupport event="onchange" action="{!resetFilter}" rerender="contactENlistview" status="ajaxStatus"/>

    <apex:commandButton action="{!save}" value="Load List View" id="loadListView"/>
    <!--Mass Delete Button-->
    <!--Mass Update Owner Button-->
    <!--Create new list view button-->


</apex:pageBlock> <!-- /formatting for the page -->
<apex:pageblock ><!-- formatting for the page -->
<apex:outputPanel id="contactENlistview" rendered="{!conFilterName != null}">

    <c:ContactListViewComponent listViewName="{!conFilterName}"  />

</apex:pageblock> <!-- /formatting for the page -->
  • 1
    As a quick aside, please consider upvoting answers you find helpful and, after a while, accepting (click the checkmark under the answer's vote score) the answer that solved your problem or was the most helpful to you. Accepting an answer tends to discourage other people from writing further answers, so it's best to leave that until you're pretty sure your problem is solved. Beyond getting those oh-so-sweet internet points, upvotes and accepted answers help direct other people visiting this question with a similar problem to the approaches that are more likely to work.
    – Derek F
    Commented Apr 16, 2020 at 18:30
  • Hi David, my apologies on the delayed response, I'm usually in the Marketing Cloud world, not development and was called away to other projects. Yes, this is a great help, thank you! Commented Apr 16, 2020 at 22:29

1 Answer 1


The error text is pointing you to the problem. You have commented out - functionally, removed - the method resetFilter, but that method is used in the Visualforce page here:

    <apex:actionSupport event="onchange" action="{!resetFilter}" rerender="contactENlistview" status="ajaxStatus"/>

If you wish to save the Apex class without that method, you must remove the reference to it in Visualforce.

The logical structure of this class is very difficult to follow because of the way that you've commented out elements like method declarations and the bodies of code blocks. At present, it's definitely not going to do what you're aiming to do, because the body of the partially-commented constructor is still running inside your for loop.

If you want to comment out whole blocks of code, use block comments:


... code ..


Or simply delete it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .