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
StoneShot_GazStoneShot_Gaz 

StandardSetController.getListViewOptions only returning All

Hi,

 

I am currently trying to retrieve a set of list view options for a Lead object from a StandardSetController. When I look at the SelectOptions that are returned (from getLeadExistingViews) I only recieve the All option in my list. The end result I would like is the list view options for the standard Lead page (All Open Leads etc.) Your help would be much appreciated. Markup and code below.

 

Gaz

 

EmailPreferenceAddMembers.page

<apex:page standardController="Email_Preference_Member__c" recordSetVar="members" extensions="EmailPreferenceAddMembersExtensions">
  <apex:sectionHeader title="{!$ObjectType.Email_Preference__c.Label}" subtitle="Add Members" />
  <apex:form >
  <apex:outputPanel style="margin-bottom: 1em;" layout="block">&laquo;&nbsp;<apex:outputLink value="http://example.org" style="color: #015BA7; text-decoration: none;">Back to Email Preference: My Email Preference</apex:outputLink></apex:outputPanel>
  <apex:pageBlock >
      <apex:pageBlockSection title="Step 1: Choose Member Type to Search">
          <apex:selectRadio >
              <apex:selectOption itemLabel="Leads" itemValue="Leads" ></apex:selectOption>
              <apex:selectOption itemLabel="Contacts" itemValue="Contacts" ></apex:selectOption>
          </apex:selectRadio>
      </apex:pageBlockSection>
      <apex:pageBlockSection title="Step 2: Specify Filter Criteria">
          <apex:pageBlockSectionItem >
          <apex:outputLabel value="Use Existing View" />
              <apex:selectList value="{!leadFilterId}" size="1">
              <apex:selectOptions value="{!LeadExistingViews}"></apex:selectOptions>
              </apex:selectList>
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      <apex:facet name="footer">
          <apex:commandButton value="Go!" style="margin: 1em; width: 3em;" />
      </apex:facet>
  </apex:pageBlock>
  </apex:form>
</apex:page>

 EmailPreferenceAddMembersExtensions.cls

public with sharing class EmailPreferenceAddMembersExtensions {

    public ApexPages.StandardSetController leadsController {get; set;}
    public String leadFilterId {get; set;}

    public EmailPreferenceAddMembersExtensions(ApexPages.StandardSetController controller) {
        leadsController = new ApexPages.StandardSetController(Database.getQueryLocator([select Id, Name from Lead]));
        leadFilterId = leadsController.getFilterId();
    }
    
    public SelectOption[] getLeadExistingViews() {
        return leadsController.getListViewOptions();
    }
}

 


Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
Just resolved this issue. If you have id parameter in your URL, getListViewOptions will not work.

All Answers

turbo2ohturbo2oh

Did you ever find a solution to this issue?

Bhawani SharmaBhawani Sharma
Just resolved this issue. If you have id parameter in your URL, getListViewOptions will not work.
This was selected as the best answer
Bryan Leaman 6Bryan Leaman 6
I know this is old, but has anyone found a resolution to this? In a custom sidebar VFpage I'm trying to include a link to a particular view. I store the view name in a custom setting and lookup the ID dynamically when the VF page runs. I'd rather not have to save the exact ID for the view. It works great unless I'm on a detail page -- then I only get the "All" view returned, which isn't the view I want to link to. :( 
njo103njo103
Hello,

Am having the same issue.  Did you find a solution?
Bryan Leaman 6Bryan Leaman 6
It's a bizaare limitation in salesforce. You'll only see the "All" view if there's an id in the address bar. I changed my program to store the list view I need access to in a browser cookie when it *is* retrieved so the VF page can remember the list view for those times when it's not visible.