• AlisonR
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

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>
                      

 

I'm new to VF and created my first VF extension:

 

public class LeadSalesActH {
    
    private final Lead ld;
    
    public LeadSalesActH(ApexPages.StandardController stdController) {
        this.ld = (Lead)stdController.getRecord();
    }

    public String getName() {
        return 'LeadSalesActH';
    }
        
    public Lead getLead() {
        return [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 Lead
                where id = :ApexPages.currentPage().getParameters().get('id')];
    }

}

 I started on my test class but I'm getting stuck on the getLead() tests. Can someone put me in the right direction?

 

Test Class:

 

@isTest
private class ExtendObjectTest {

    static testmethod void constructorTest() {
        // set up some test data to work with
        Lead ld = new Lead(LastName='Test', Company='Test1', Status='New');
        insert ld;

        // start the test execution context
        Test.startTest();

        // set the test's page to your VF page (or pass in a PageReference)
        Test.setCurrentPage(Page.leadsales);

        // call the constructor
        LeadSalesActH controller = new LeadSalesActH(new ApexPages.StandardController(ld));

        // stop the test
        Test.stopTest();
    }

}

 

 

I'm creating a trigger to create a campaign member to a specific campaign. However, my edition of Salesforce only includes 1 Developer Sandbox and thus does not have the campaign needed for the trigger (no production data). What is the best way to create the trigger given this limitation? Is there a way to do it the Force.com IDE? 

  • September 17, 2013
  • Like
  • 0

I'm new to VF and created my first VF extension:

 

public class LeadSalesActH {
    
    private final Lead ld;
    
    public LeadSalesActH(ApexPages.StandardController stdController) {
        this.ld = (Lead)stdController.getRecord();
    }

    public String getName() {
        return 'LeadSalesActH';
    }
        
    public Lead getLead() {
        return [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 Lead
                where id = :ApexPages.currentPage().getParameters().get('id')];
    }

}

 I started on my test class but I'm getting stuck on the getLead() tests. Can someone put me in the right direction?

 

Test Class:

 

@isTest
private class ExtendObjectTest {

    static testmethod void constructorTest() {
        // set up some test data to work with
        Lead ld = new Lead(LastName='Test', Company='Test1', Status='New');
        insert ld;

        // start the test execution context
        Test.startTest();

        // set the test's page to your VF page (or pass in a PageReference)
        Test.setCurrentPage(Page.leadsales);

        // call the constructor
        LeadSalesActH controller = new LeadSalesActH(new ApexPages.StandardController(ld));

        // stop the test
        Test.stopTest();
    }

}