function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
uHaveOptionsuHaveOptions 

How make Subject in Visualforce Page link to Activity Task Detail Page

I have a VF Page and I just want to link the subject to the related activity detail.  What am I missing?
 
<apex:page standardController="Contact" extensions="ActivityHistoryOnContact" showHeader="true" sidebar="false" >
<div style="overflow: scroll; height: 600px;">
  <apex:pageBlock title="Activity History">
      <apex:pageBlockSection >
          <apex:pageBlockTable value="{!ListTasks}" var="tsk" html-cid="actTable" style="width:1200px" >
          <apex:column style="width:500px" headerValue="Date" value="{!tsk.LastModifiedDate}" />
              <apex:column style="width:900px" headerValue="Subject" value="{!tsk.Subject}" />
              <a href="/{!tsk.Subject}" target="_blank">{!tsk.Subject}</a>
              <apex:column style="width:2500px" headerValue="Comments" value="{!tsk.Description}"/>
          </apex:pageBlockTable>
      </apex:pageBlockSection> 
  </apex:pageBlock>
  </div>
</apex:page>

 
Best Answer chosen by uHaveOptions
James WooleyJames Wooley
Sorry I hadn't realised but your link was in slightly the wrong place. The following code will fix your probelms.
 
<apex:page standardController="Contact" extensions="ActivityHistoryOnContact" showHeader="true" sidebar="false" >
<div style="overflow: scroll; height: 600px;">
  <apex:pageBlock title="Activity History">
      <apex:pageBlockSection >
          <apex:pageBlockTable value="{!ListTasks}" var="tsk" html-cid="actTable" style="width:1200px" >
          <apex:column style="width:500px" headerValue="Date" value="{!tsk.LastModifiedDate}" />
              <apex:column style="width:900px" headerValue="Subject">
                  <apex:outputLink value="/{!tsk.Id}">{!tsk.Subject}</apex:outputLink>
             </apex:column>
              <a href="/{!tsk.Id}" target="_blank">{!tsk.Subject}</a>
              <apex:column style="width:2500px" headerValue="Comments" value="{!tsk.Description}"/>
          </apex:pageBlockTable>
      </apex:pageBlockSection> 
  </apex:pageBlock>
  </div>
</apex:page>

Thanks.

All Answers

James WooleyJames Wooley
The link needs to go to the task Id, rather than the subject.
 
<apex:page standardController="Contact" extensions="ActivityHistoryOnContact" showHeader="true" sidebar="false" >
<div style="overflow: scroll; height: 600px;">
  <apex:pageBlock title="Activity History">
      <apex:pageBlockSection >
          <apex:pageBlockTable value="{!ListTasks}" var="tsk" html-cid="actTable" style="width:1200px" >
          <apex:column style="width:500px" headerValue="Date" value="{!tsk.LastModifiedDate}" />
              <apex:column style="width:900px" headerValue="Subject" value="{!tsk.Subject}" />
              <a href="/{!tsk.Id}" target="_blank">{!tsk.Subject}</a>
              <apex:column style="width:2500px" headerValue="Comments" value="{!tsk.Description}"/>
          </apex:pageBlockTable>
      </apex:pageBlockSection> 
  </apex:pageBlock>
  </div>
</apex:page>

 
uHaveOptionsuHaveOptions
That did not work.
uHaveOptionsuHaveOptions
:(
James WooleyJames Wooley
You could try using a Apex OutputLink instead of the a tag https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputLink.htm. If this doesn't work, could you paste your ActivityHistoryOnContact controller code so that I can see what ListTasks is?

Thanks.
James WooleyJames Wooley
Also, what does this page look like when loaded up? Can you send a screenshot?
uHaveOptionsuHaveOptions
I dont think its a APEX issue maybe it it is but here is the APEX and the screen shot.  I just need to be able to generate a link on the subject so they can click and open the activity detail.
 
I dont think its a APEX issue maybe it it is but here is the APEX and the screen shot.  I just need to be able to generate a link on the subject so they can click and open the activity detail.

public class ActivityHistoryOnContact{


public String currentUser = UserInfo.getUserId();
public String currentContact = ApexPages.currentPage().getParameters().get('id');
    public String taskList {get;set;}
    public String soql {get;set;}



    public Task[] getListTasks() {

//                       taskList = 'select whoid,subject,status,LastModifiedDate, WhatID, Description, Primary_Contact_Phone_Number__c, Primary_Contact_Email_Address__c, Call_Result__c, Last_Call_Date__c, Last_Call_Agent__c from task WHERE CreatedbyId=\''+currentUser+'\' AND (subject LIKE \'call%\' OR subject LIKE \'outbound%\') AND WhoID =\''+currentContact+'\' order by LastModifiedDate desc limit 20000'; 
 taskList = 'select whoid,subject,status,LastModifiedDate, WhatID, Description, Primary_Contact_Phone_Number__c, Primary_Contact_Email_Address__c, Call_Result__c, Last_Call_Date__c, Last_Call_Agent__c from task WHERE CreatedbyId=\''+currentUser+'\' AND WhoID =\''+currentContact+'\' order by LastModifiedDate desc limit 20000';  
 

   //delete duplicate property records
        List<Task> tskList = Database.query(taskList);
        System.debug('#########tskListInit'+tskList);
    
             System.debug('#########tskListFinal'+tskList);
        return tskList;     
    
}

   public ActivityHistoryOnContact(ApexPages.StandardController controller){}



     
      
}


User-added image

​Let me know.  Thanks

User-added image


​Let me know.  Thanks
James WooleyJames Wooley
Sorry I hadn't realised but your link was in slightly the wrong place. The following code will fix your probelms.
 
<apex:page standardController="Contact" extensions="ActivityHistoryOnContact" showHeader="true" sidebar="false" >
<div style="overflow: scroll; height: 600px;">
  <apex:pageBlock title="Activity History">
      <apex:pageBlockSection >
          <apex:pageBlockTable value="{!ListTasks}" var="tsk" html-cid="actTable" style="width:1200px" >
          <apex:column style="width:500px" headerValue="Date" value="{!tsk.LastModifiedDate}" />
              <apex:column style="width:900px" headerValue="Subject">
                  <apex:outputLink value="/{!tsk.Id}">{!tsk.Subject}</apex:outputLink>
             </apex:column>
              <a href="/{!tsk.Id}" target="_blank">{!tsk.Subject}</a>
              <apex:column style="width:2500px" headerValue="Comments" value="{!tsk.Description}"/>
          </apex:pageBlockTable>
      </apex:pageBlockSection> 
  </apex:pageBlock>
  </div>
</apex:page>

Thanks.
This was selected as the best answer
uHaveOptionsuHaveOptions
@jameswooley thanks for the update.  I was able to fix this and even made the link open on a different tab.  I also removed the "a href" it didnt make sense.  Here is my new code. 
 
<apex:page standardController="Contact" extensions="ActivityHistoryOnContact" showHeader="true" sidebar="false" >
<div style="overflow: scroll; height: 600px;">
  <apex:pageBlock title="Activity History">
      <apex:pageBlockSection >
          <apex:pageBlockTable value="{!ListTasks}" var="tsk" html-cid="actTable" style="width:1000px" >
          <apex:column style="width:200px" headerValue="Date" value="{!tsk.LastModifiedDate}" />
              <apex:column style="width:200px" headerValue="Subject" >
              <apex:outputLink value="/{!tsk.id}" target="_blank">{!tsk.Subject}</apex:outputLink> </apex:column>
              <apex:column style="width:1000px" headerValue="Comments" value="{!tsk.Description}"/>
          </apex:pageBlockTable>
          </apex:pageBlockSection> 
  </apex:pageBlock>
  </div>
</apex:page>

 
James WooleyJames Wooley
That's great, glad you were able to resolve the issue!