You need to sign in to do that
Don't have an account?
AlisonR3
How do I limit my collection to 1,000 rows?
So I'm getting an error on some accounts when using the following extension controller. I'm not looking to get around the limit of 1,000, merely to restrict my collection to 1,000 so it will display. The following is my extension controller and despite limiting the query to 1,000 I still get an error on pages over 1,000.
public class AccountSalesActH { private final Account acct; public AccountSalesActH(ApexPages.StandardController stdController) { this.acct = (Account)stdController.getRecord(); } public String getName() { return 'AccountSalesActH'; } public Account getAccount() { Account[] acct = [select id, name, ownerid, (select subject, who.name, createdby.name, whatid, whoid, activitydate, LVM__c, ownerid, lastmodifieddate from ActivityHistories where ownerid not in ('00530000000vpI1') order by activitydate DESC LIMIT 1000) //filter out marketing actvities from Account where id = :ApexPages.currentPage().getParameters().get('id')]; if (acct.size()>0) {return acct[0];} else {return null; } }}
you might want to take a look at this and this will help you out/
http://boards.developerforce.com/t5/Apex-Code-Development/Governor-limits-for-sub-query-in-query-locator-Batch-apex/m-p/492617#M90951
The error doesn't happen when there is less than 1,000 activities on the account that match the query conditions. The error only happens when there are more than 1,000 activities that match the query conditions. I've tested and those with 900 something activities that match, I don't get an error.
Here is an example of the error message I get:
Content cannot be displayed: INVALID_TYPE_FOR_OPERATION: entity type ActivityHistory does not support query
I still get the error no matter what I set as LIMIT, even if its just 1 record.
The error sometimes varies, here's an example of another error I get when the activity count is closer to 1,000 (when its super high - +3,000 I get that other error):
Content cannot be displayed: Collection size 1,542 exceeds maximum size of 1,000.
Basically I have 2 controller extensions one that includes all activities logged by sales and one that includes all activities logged by marketing. I'm setting them up as separate related lists on the account so as to reduce the clutter when looking through the traditional related list: "Activity History".