You need to sign in to do that
Don't have an account?

Visual force page to display the Activity History
Hello all,
I am new to salesforce. And this is my first try at VisualForce Page in an organization.
The requirement is to display the activity history in a seperate page. Right now, since activity history is a related list in Accounts/Contacts, the information gets displayed in the same page as in Accounts/contacts.
I am planning to write a VF page and give a button on the related list, which will take the users to a new page of activity history.
Here is the VF page and the related class. I am getting a List has no rows for assignment to SObject errors.The error comes when i click the button.
Can anyone please help me out.
<apex:page standardController="Task" extensions="MarketingGeniusTasksController">
<apex:form >
<h1>Activity History: Marketing Genius Emails</h1>
<apex:pageblock >
<apex:pageBlockTable value="{!Task}" var="Task" >
<apex:column headerValue="Status"/>
<apex:outputfield value="{!task.Status}"/>
<apex:column headerValue="Subject"/>
<apex:outputfield value="{!task.Subject}"/>
<apex:column headerValue="Priority"/>
<apex:outputfield value="{!task.Priority}"/>
<apex:column headerValue="TLC Activity Type"/>
<apex:outputfield value="{!task.Vmail__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public class MarketingGeniusTasksController
{
Task tk;
Task tsk;
public MarketingGeniusTasksController(ApexPages.StandardController stdController)
{
this.tk = (Task)stdController.getRecord();
tsk = [Select Status, Subject, Priority, Vmail__c from Task where Id=:tk.Id]; -->error at this line.
}
public string getStatus(){
return tsk.Status;
}
public string getSubject(){
return tsk.Subject;
}
public string getPriority(){
return tsk.Priority;
}
public string getTLCActivityType(){
return tsk.Vmail__c;
}
}
You shouldn't be using the standard controller for task since you don't intend to display one task. You might want to write your controller as a custom controller (with controller attribute defined in apex:page tag) for this. You would also pass the parent record id (account or contact) as a parameter to this vf page, which you can read in a "init" method and query tasks by parent id field. Hope this helps!
Thank you for the reply.
Will try out your solution and if i run into any issues, will post it.
Thanks once again!
I made some modifications in my code. Now it is displaying all the activities created in the organiztion. I want to filter it out based on the particular Account or Contact. Any suggestions on how i can accomplish that with the code i already have.
Thank you!!
Since i am new to Salesforce, can you please suggest me on how to pass the parent record id as a parameter to the vf page?
Thanks in advance!