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>();
optyList.clear();
isSuccess = false;
tooManyResults = false;
if (filterId <> null && filterId<> 'None'){
optySetController.setFilterId(filterId);
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));
counter++;
if (counter==999){
tooManyResults=true;
break;
}
}
}
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".
Update
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...