If I take an org with over 50000 Account
records and run this snippet, I don't get any errors and I do get the expected output:
ApexPages.StandardSetController controller = new ApexPages.StandardSetController([
SELECT Id FROM Account LIMIT 50000
]);
system.debug(controller.getCompleteResult()); // false
system.debug(controller.getResultSize()); // 10000
And I also get the expected output if the LIMIT
is at or below 10000
.
ApexPages.StandardSetController controller = new ApexPages.StandardSetController([
SELECT Id FROM Account LIMIT 10000
]);
system.debug(controller.getCompleteResult()); // true
system.debug(controller.getResultSize()); // 10000
I tested these with API Version set all the way down to 10 on my Apex Class
and 15 on my Visualforce Page
, and did not receive an error. Perhaps you open another query locator somewhere else on your page somewhere.
<apex:page controller="Throwaway">
<apex:outputText value="{!IF(controller.completeResult, 'complete', 'partial')}" />
</apex:page>
<!--
public with sharing class Throwaway
{
public ApexPages.StandardSetController controller
{
get
{
if (controller == null)
controller = new ApexPages.StandardSetController([
SELECT Id FROM Account LIMIT 50000
]);
return controller;
}
private set;
}
}
-->