+ Start a Discussion
bikla78bikla78 

Visual Force New page hyperlink

I created a VF page that pulls the related events for a particular contact. This is currently set within the contact page layout. However, how can I make it so that when a user clicks on the subject field it takes them to the event page layout for the event record?

 

 

2
3
4
5
6
7
8
9
10
11
12
13
14
public class ActivityController {
    private final Contact cont;
    public ActivityController(ApexPages.StandardController controller) {
        this.cont = (Contact)controller.getRecord();
    }
    Public Event[] getActivities(){
        return [Select id, subject, what.id, who.id, type, activitydate from Event 
               where whoid=:cont.id ];

    }
    

    

 

 

<apex:page standardController="contact"   extensions="ActivityController">
<apex:pageBlock title="Event History" >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.activitydate}" />
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.whoid}"/>
<apex:column value="{!a.whatid}"/>
<apex:column value="{!a.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

SteveBowerSteveBower

Add an onClick javascript action to the Column for the Subject.

 

<apex:column vale="{!a.subject}" onclick="window.top.location=/{!a.id}" />

 

Note: This won't work if your VF page is being displayed inside an iframe on some other page as you'll only redirect the VF page, and not the whole window.

 

Best, Steve

bikla78bikla78

Steve thanks for this information

 

Right now, I am trying to seperate the event and task history since the standard activityhistory related list can not be modified and it's getting too cumbersome for the users with both events and tasks in 1 section.  I can't place the VF page into the activity history related list so I experiented by embedding the vfpages into the Iframe of the contact page detal layout page.  Do I have to create a new custom object all together called event history and task history and attach it to the contact related list then place the vf page? I could do this but it may be complex to setup since we have so many workflow customization against events and tasks

 

 I read on the forums that the activityhistory object fields can not be accessed through the schema. When I tried to run a query it says " INVALID_TYPE_FOR_OPERATION- entity type activityhistory does not support query".  The query i ran was basically

 

select ID from activityhistory

 

Any ideas would be great

 

thanks