I have an Opportunity listview which returns 5 results but when I try to use this in the ApexPages.StandardSetController the getResultSize() call returns zero.

Here is the code that is called once the user has selected a list view from the drop down:

public void refreshOptyList(){
    list<Opportunity> testList = new list<Opportunity>();

    isSuccess = false;
    tooManyResults = false;
    if (filterId <> null && filterId<> 'None'){
         testList = (list<Opportunity>)optySetController.getRecords();
         searchPerformed = true;
    } else searchPerformed = false;

    System.debug('Filter used=>'+filterId);
    System.debug('Result #=>'+optySetController.getResultSize());

    Integer counter=0;
    for (Opportunity opty:testList){
        optyList.add(new cOpty(Opty));
        if (counter==999){


The filter id in the debug log is the correct one and the getResultSize() returns zero.

The filters for the list view are as follows:

  • Custom Date Field >= 01/01/2015
  • Custom Lookup To Account = hard coded string
  • Stage != Won, Not Won
  • Owner Full Name = "Lastname, Firstname"

Owner filter is set to "All Opportunities" and the list view is "Visible to all users".


The StandardSetController is instantiated in the constructor of the class:

public MassReassignOpportunitiesController(){

    //Variable Init
    optyQueryString = 'SELECT name,StageName,Ownerid,CloseDate from Opportunity where isDeleted=false';
    optyList = new List<cOpty>();
    optySetController = new ApexPages.Standardsetcontroller(Database.getQueryLocator(optyQueryString+' limit 1000'));

I should also mention that selecting other list views does return results - I can't yet find a pattern to this though...


1 Answer 1


Ok, problem solved.

There appears to be some form of bug with using the Owner Full Name field.

I removed this filter:

  • Owner Full Name = "Lastname, Firstname"

and added these 2 filters instead:

  • Owner First Name = Firstname
  • Owner Last Name = Lastname

And now the results are being returned as expected.

You must log in to answer this question.

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