You need to sign in to do that
Don't have an account?
ActivityHistory not displaying Related To on VF page
the Apex class:
public with sharing class AcctActivityList{
public Account acct {get; set;}
public List<ActivityHistory> ClosedTasks {get; set;}
string mail = 'mail';
public AcctActivityList(ApexPages.StandardController stdcontroller) {
//get account
acct = (Account)stdController.getRecord();
//get activity history - can't query activity history directly, just in a subquery against another object
SObject[] ActivityHistory = [Select id, (select Id, AccountId, Account.Name, ActivityDate, ActivityType, Description, OwnerId, Subject,
LastModifiedDate, IsTask, WhatId, WhoId from ActivityHistories where
(ActivityType !='Email') ORDER by ActivityDate DESC)
from Account where Id =: acct.id];
ClosedTasks = (List<ActivityHistory>)ActivityHistory.get(0).getSObjects('ActivityHistories');
}
}
The vf page:
<apex:page standardcontroller="Account" extensions="AcctActivityList">
<apex:pageBlock title="Activity History">
<apex:pageBlockTable value="{!ClosedTasks}" var="ah" >
<apex:column headerValue="Subject">
<apex:outputLink value="/{!ah.id}">{!ah.Subject}</apex:outputlink>
</apex:column>
<apex:column headervalue="Name" value="{!ah.AccountId}"/>
<apex:column headervalue="Related To" value="{!ah.WhatId}"/>
<apex:column value="{!ah.IsTask}"/>
<apex:column headerValue="Due Date" value="{!ah.ActivityDate}"/>
<apex:column value="{!ah.OwnerId}"/>
<apex:column value="{!ah.LastModifiedDate}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
How do I get Related To to appear on the Visualforce page?
See where I refer to WhatId on the vf page? This results in the error "Content cannot be displayed: U#324.4ff (What): InvalidForeignKeyValue, 001f000000DQ9AyAAL" appearing on the page. Now, that "foreign key" is actually the account id of the account on which this is being displayed. That shouldn't be an issue tho - AccountId above it displays fine if I take out the reference to WhatId. I need to show Related To in the list - anyone know how I can do that?
public with sharing class AcctActivityList{
public Account acct {get; set;}
public List<ActivityHistory> ClosedTasks {get; set;}
string mail = 'mail';
public AcctActivityList(ApexPages.StandardController stdcontroller) {
//get account
acct = (Account)stdController.getRecord();
//get activity history - can't query activity history directly, just in a subquery against another object
SObject[] ActivityHistory = [Select id, (select Id, AccountId, Account.Name, ActivityDate, ActivityType, Description, OwnerId, Subject,
LastModifiedDate, IsTask, WhatId, WhoId from ActivityHistories where
(ActivityType !='Email') ORDER by ActivityDate DESC)
from Account where Id =: acct.id];
ClosedTasks = (List<ActivityHistory>)ActivityHistory.get(0).getSObjects('ActivityHistories');
}
}
The vf page:
<apex:page standardcontroller="Account" extensions="AcctActivityList">
<apex:pageBlock title="Activity History">
<apex:pageBlockTable value="{!ClosedTasks}" var="ah" >
<apex:column headerValue="Subject">
<apex:outputLink value="/{!ah.id}">{!ah.Subject}</apex:outputlink>
</apex:column>
<apex:column headervalue="Name" value="{!ah.AccountId}"/>
<apex:column headervalue="Related To" value="{!ah.WhatId}"/>
<apex:column value="{!ah.IsTask}"/>
<apex:column headerValue="Due Date" value="{!ah.ActivityDate}"/>
<apex:column value="{!ah.OwnerId}"/>
<apex:column value="{!ah.LastModifiedDate}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
How do I get Related To to appear on the Visualforce page?
See where I refer to WhatId on the vf page? This results in the error "Content cannot be displayed: U#324.4ff (What): InvalidForeignKeyValue, 001f000000DQ9AyAAL" appearing on the page. Now, that "foreign key" is actually the account id of the account on which this is being displayed. That shouldn't be an issue tho - AccountId above it displays fine if I take out the reference to WhatId. I need to show Related To in the list - anyone know how I can do that?
If you can live without the hover popup on the related item, you can query back the whatid and related name use those to build a link in the column body:
SObject[] ActivityHistory = [Select id, (select Id, AccountId, Account.Name, ActivityDate, ActivityType, Description, OwnerId, Subject,
LastModifiedDate, IsTask, WhatId, What.Name, WhoId from ActivityHistories where
(ActivityType !='Email') ORDER by ActivityDate DESC)
from Account where Id =: acct.id];
...
<apex:column headervalue="Related To">
<apex:outputLink value="/{!ah.WhatId}">{!ah.What.Name}</apex:outputLink>
</apex:column>