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
bikla78bikla78 

Contact Activity History

I have created this visual force page with an APEX controller. However, how can I get the edit link under "Action" next to each record? This is the same "edit" link under activity history on left side of each record. What visual force tag would do this?

Edit

 

Also how can i also put the link that says if there are a certain amount of record under mycustom  task history vf page?

 

<apex:page standardController="contact"   extensions="TaskController">
<apex:pageBlock title="Task History" >
<apex:pageBlockTable value="{!Tasks}" var="t">
<apex:column value="{!t.activitydate}" />
<apex:column value="{!t.subject}"/>
<apex:column value="{!t.whoid}"/>
<apex:column value="{!t.whatid}"/>
<apex:column value="{!t.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

public class TaskController {
    private final Contact cont;
    public TaskController(ApexPages.StandardController controller) {
        this.cont = (Contact)controller.getRecord();
    }
    Public Task[] getTasks(){
        return [Select id, subject, what.id, who.id, type, activitydate from Task
               where whoid=:cont.id ];
    }

}

bob_buzzardbob_buzzard

For the first, you'd need to add a column titled 'Action' and output a CommandLink that takes you to the edit page for the record you are iterating.

 

For the latter, you'd need to construct these links yourself and add them to the page beneath your table.

 

 

Shailesh DeshpandeShailesh Deshpande

do you mean you want to have an Edit link on the left side of each record that takes the user to the edit page when he clicks on it?

 

if thats the case then you can use the <apex:outputLink> tag...

 

 

<apex:smileytongue:age standardController="contact"   extensions="TaskController">
<apex:smileytongue:ageBlock title="Task History" >
<apex:smileytongue:ageBlockTable value="{!Tasks}" var="t">

 

<apex:column headerValue="Action">
      <apex:outputLink value="/{!t.Id}/e?retURL=/apex/{!$CurrentPage.Name}"><b>Edit</b></apex:outputLink>

   </apex:column> 


<apex:column value="{!t.activitydate}" />
<apex:column value="{!t.subject}"/>
<apex:column value="{!t.whoid}"/>
<apex:column value="{!t.whatid}"/>
<apex:column value="{!t.type}"/>
</apex:smileytongue:ageBlockTable>
</apex:smileytongue:ageBlock>
</apex:smileytongue:age>

 

 

I hope this helps..

bikla78bikla78

Thanks. 2 things

 

1.  The header value Action label appeared but not the edit link next to the record..it's just white space

 

2.  How do i only show a maximum of 5 records on this vf page and if I want to see more there are these links at the bottom left of the page. I thought these links would be the easier part for me after I got the MVC created but guess not..=)

 

<apex:page standardController="contact"   extensions="TaskController">
<apex:pageBlock title="Task History" >
<apex:pageBlockTable value="{!Tasks}" var="t">
<apex:column headerValue="Action"/>
<apex:outputLink >"/{!t.Id}/e?retURL=/apex/{!$CurrentPage.Name}"><b>Edit</b></apex:outputLink><apex:column />
<apex:column value="{!t.activitydate}" />
<apex:column value="{!t.subject}"/>
<apex:column value="{!t.whoid}"/>
<apex:column value="{!t.whatid}"/>
<apex:column value="{!t.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Shailesh DeshpandeShailesh Deshpande

you are closing the column tag and then writing the outputlink..also in outputlink you are not giving the url in value attribute...

 

this is what you have done :

 

<apex:column headerValue = "Action" />

<apex:outputLink>"/{!t.Id}/e?retURL=/apex/{!$CurrentPage.Name}"><b>Edit</b></apex:outputLink>

 

 

instead you need to do this

 

<apex:column headerValue="Action">
      <apex:outputLink value="/{!t.Id}/e?retURL=/apex/{!$CurrentPage.Name}"><b>Edit</b></apex:outputLink>
</apex:column>

bikla78bikla78

This worked! but there are few more issue

 

1. How can I get these links at the bottom of the page. I can change my query to limit 5

Show more » | Go to list »

2. Although the edit link works when I click on it, it bring up the page into the section I place the vf in the page layout so it shows the task record within the wideth and height boundary so it doesn;t look good. How can I do this so when the click on edit it opens it up in a new page?
3. How can I make it so that when they click on the "subject" column it opens up a new page and shows the task record. I need to find a way to hyperlink
4. Like #2, when I click on the contact name field (name), it shows up thepage then goes away. I need to also have it bring up a new page window.
This is alot more difficult than I anticipated
Perhaps this best way is to make the task history vf page a related list. How could I assocuiate a vfpage as a related list? This way, this task history will show up at the bottom of contact record