• AlisonR3
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

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;
    }

}}

 

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;
    }

}}

 

So I've created an controller extension and have added a visualforce page to my account layout. It all works fine and dandy except for a few accounts I get this error: "Content cannot be displayed: INVALID_TYPE_FOR_OPERATION: entity type ActivityHistory does not support query". I believe it has to do with the fact that the accounts that seem to error have a large amount of activity history. However, when I add a LIMIT to the controller extension it still errors. How do we fix this?

 

Apex Class:

 

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, whatid, whoid, activitydate, LVM__c, ownerid, lastmodifieddate from ActivityHistories 
                     where ownerid not in ('00530000000vpI1') order by activitydate DESC ) //filter out marketing actvities 
                from Account
                where id = :ApexPages.currentPage().getParameters().get('id')]; if (acct.size()>0) {return acct[0];} else {return null;
    }

}}

 

Visualforce page:

 

<apex:page standardController="Account" extensions="AccountSalesActH">
<br />

<apex:pageBlock title="Sales Activity History">
<div style="padding-left:33%">
<apex:outputLink styleClass="btn" onclick="window.parent.location='/00T/e?title=Call&who_id={!Account.Id}&followup=1&tsk5=Call&retURL=%2F{!Account.id}'" style="text-decoration:none">Log a Call</apex:outputLink>
<apex:outputLink styleClass="btn" onclick="window.parent.location='/apex/accountsales?id={!Account.Id}'" style="text-decoration:none">View All</apex:outputLink></div><br />

<apex:pageBlockTable value="{!Account.ActivityHistories}" var="hist" rows="5">
<apex:column headerValue="Action">
      <apex:outputLink value="/{!hist.Id}/e?retURL=/apex/{!$CurrentPage.Name}" target="_parent" style="color: #015ba7;
text-decoration: none;
font-weight: normal;">Edit</apex:outputLink> <span style="color:#999">|</span>&nbsp;
      <apex:outputLink value="/{!hist.Id}" target="_parent" style="color: #015ba7;
text-decoration: none;
font-weight: normal;">View</apex:outputLink>
</apex:column>

            <apex:column value="{!hist.subject}"/>
            <apex:column value="{!hist.whoid}"/>
            <apex:column value="{!hist.activitydate}"/>
            <apex:column value="{!hist.LVM__c}"/>
            <apex:column value="{!hist.ownerid}"/>
            <apex:column value="{!hist.lastmodifieddate}"/>  
    </apex:pageBlockTable><br />
    <apex:outputLink onclick="window.parent.location='/apex/accountsales?id={!Account.Id}'">Go to List >></apex:outputLink>
    <base target="_parent"/>
</apex:pageBlock>


</apex:page>