If I have a StandardSetController and an object ID, is there a way to check whether the object would be included in the StandardSetController, short of looping through all of its objects? Best described by example:
String query = 'SELECT Id, Name FROM Account
WHERE SomeCriteria = :someValue
ORDER BY AnotherField';
StandardSetController ssc = new StandardSetController(query);
Account thisAccount = howeverYouGetTheAccount();
// Question 1: Is this account included in the SetController?
Boolean isAccountInSet = ???;
// Bonus 2: On what page of results or in what index?
Integer page = ???;
Integer index = ???;
ssc.setPageNumber(page);
List<Account> records = ssc.getRecords();
System.AssertEquals(thisAccount.Id, records.get(index).Id);
Again, I know I could iterate through all the results... but that could be thousands of results and is really inefficient.
UPDATES:
A query locator is required in this case, because we might have thousands of results, and a
ListorSetwould overflow the heap.My example is simplified. In reality, we have about 10 various criteria running on this search, so while I could recreate it and do a binary search for the item in question, that might be a bit messy...
