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

Conditional Display of records on Visualforce page
Dear All,
I have created a visualforce page wherein I am getting all Tasks and Email records from the Case. I am showing them in the chronological order.
I have created another component (not working and need help) on Visualforce page which allow users to either select Tasks or Emails and then click on 'Show' button. Depending on the selection on visualforce page, user would either see Tasks or Emails on the visualforce page. Any help/pointers would help alot.

*************************************Here is the code of my controller********************************************
public with sharing class CaseEmailExtension {
private final Case currentCase;
public CaseEmailExtension(ApexPages.StandardController currentcase) {
this.currentCase = (Case)currentcase.getRecord();
}
public List<EmailMessage> getSortEmails(){
List <EmailMessage> sortedEmails = new List<EmailMessage>();
sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, MessageDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name
from EmailMessage where ParentId =: currentCase.Id
order by MessageDate DESC ];
return sortedEmails;
}
public List<Task> getTask() {
List<Task> Task= new List<Task>();
Task = [SELECT Id, Priority, Subject, Status, Description, CreatedDate, ActivityDate, CreatedBy.Name,Who.Name
from Task order by CreatedDate DESC];
return Task;
}
}
********************************Here is Visualforce Page code*****************************
</apex:pageBlock>
<apex:pageblock >
<apex:pageBlockSection id="RelatedList" columns="2" title="Related List Selection" collapsible="true">
<apex:selectcheckboxes layout="pageDirection">
<apex:selectOption itemLabel="Tasks and Activities" itemValue="Tasks"/>
<apex:selectOption itemLabel="Emails" itemValue="EMAIL"/>
</apex:selectcheckboxes>
<apex:outputPanel layout="none">
<apex:commandButton value="Show" />
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
I have created a visualforce page wherein I am getting all Tasks and Email records from the Case. I am showing them in the chronological order.
I have created another component (not working and need help) on Visualforce page which allow users to either select Tasks or Emails and then click on 'Show' button. Depending on the selection on visualforce page, user would either see Tasks or Emails on the visualforce page. Any help/pointers would help alot.
*************************************Here is the code of my controller********************************************
public with sharing class CaseEmailExtension {
private final Case currentCase;
public CaseEmailExtension(ApexPages.StandardController currentcase) {
this.currentCase = (Case)currentcase.getRecord();
}
public List<EmailMessage> getSortEmails(){
List <EmailMessage> sortedEmails = new List<EmailMessage>();
sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, MessageDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name
from EmailMessage where ParentId =: currentCase.Id
order by MessageDate DESC ];
return sortedEmails;
}
public List<Task> getTask() {
List<Task> Task= new List<Task>();
Task = [SELECT Id, Priority, Subject, Status, Description, CreatedDate, ActivityDate, CreatedBy.Name,Who.Name
from Task order by CreatedDate DESC];
return Task;
}
}
********************************Here is Visualforce Page code*****************************
</apex:pageBlock>
<apex:pageblock >
<apex:pageBlockSection id="RelatedList" columns="2" title="Related List Selection" collapsible="true">
<apex:selectcheckboxes layout="pageDirection">
<apex:selectOption itemLabel="Tasks and Activities" itemValue="Tasks"/>
<apex:selectOption itemLabel="Emails" itemValue="EMAIL"/>
</apex:selectcheckboxes>
<apex:outputPanel layout="none">
<apex:commandButton value="Show" />
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
Donot forget to select best answer to make our efforts visible in the developer forum.
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
<apex:page controller="className">