You need to sign in to do that
Don't have an account?
Pratik Pawar
Error : Return type of an Apex action method must be a PageReference. Found: visualforce.el.VisualforceArrayList
Any clue on error.
/*********************************************VF Page*****************************************/
<apex:page standardController="Account" extensions="getSingleRelatedList">
<apex:form >
<apex:detail relatedList="false"/>
<apex:selectList value="{!selectString }" multiselect="false" size="1">
<b>Record Type :</b> <apex:selectoptions value="{!Items}"/>
<apex:actionSupport event="onchange" action="{!ClientRelatedList}" rerender="conList"/>
</apex:selectList> <br/> <br/>
</apex:form>
<apex:relatedList list="Contacts" title="Employee Contacts" id="conList">
<apex:facet name="body">
<apex:pageBlock id="pageBlock">
<apex:pageBlockTable value="{!listContactClientRecT}" var="con">
<apex:column headerValue="Name">
<apex:outputLink value="/{!con.Id}">{!con.FirstName} {!con.LastName}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:facet>
</apex:relatedList>
</apex:page>
/**********************************Controller****************************************/
public class getSingleRelatedList {
public List<Contact> listContactClientRecT{get; set;}
public List<String> listRecordType {get; set;}
public String selectString {get; set;}
public ID accId {set; get;}
public getSingleRelatedList(ApexPages.StandardController controller) {
listRecordType = new List<String>();
listContactClientRecT = new List<Contact>();
accId = controller.getId();
}
public pageReference getClientRelatedList(){
listContactClientRecT = [Select Id,FirstName,LastName, RecordTypeId from Contact where RecordTypeId =:selectString];
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
List<Contact> listContactRecTypeId =[Select RecordTypeId from contact where AccountId =: accId];
Set<ID> rectypeID = new Set<ID>();
for(Contact objContact : listContactRecTypeId ){
rectypeID.add(objContact.RecordTypeId);
}
if(listContactRecTypeId!=Null && !listContactRecTypeId.isEmpty())
for(ID objContact: rectypeID){
options.add(new SelectOption(objContact,objContact));
}
return options;
}
}
/*********************************************VF Page*****************************************/
<apex:page standardController="Account" extensions="getSingleRelatedList">
<apex:form >
<apex:detail relatedList="false"/>
<apex:selectList value="{!selectString }" multiselect="false" size="1">
<b>Record Type :</b> <apex:selectoptions value="{!Items}"/>
<apex:actionSupport event="onchange" action="{!ClientRelatedList}" rerender="conList"/>
</apex:selectList> <br/> <br/>
</apex:form>
<apex:relatedList list="Contacts" title="Employee Contacts" id="conList">
<apex:facet name="body">
<apex:pageBlock id="pageBlock">
<apex:pageBlockTable value="{!listContactClientRecT}" var="con">
<apex:column headerValue="Name">
<apex:outputLink value="/{!con.Id}">{!con.FirstName} {!con.LastName}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:facet>
</apex:relatedList>
</apex:page>
/**********************************Controller****************************************/
public class getSingleRelatedList {
public List<Contact> listContactClientRecT{get; set;}
public List<String> listRecordType {get; set;}
public String selectString {get; set;}
public ID accId {set; get;}
public getSingleRelatedList(ApexPages.StandardController controller) {
listRecordType = new List<String>();
listContactClientRecT = new List<Contact>();
accId = controller.getId();
}
public pageReference getClientRelatedList(){
listContactClientRecT = [Select Id,FirstName,LastName, RecordTypeId from Contact where RecordTypeId =:selectString];
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
List<Contact> listContactRecTypeId =[Select RecordTypeId from contact where AccountId =: accId];
Set<ID> rectypeID = new Set<ID>();
for(Contact objContact : listContactRecTypeId ){
rectypeID.add(objContact.RecordTypeId);
}
if(listContactRecTypeId!=Null && !listContactRecTypeId.isEmpty())
for(ID objContact: rectypeID){
options.add(new SelectOption(objContact,objContact));
}
return options;
}
}
i have updated your code to get ride of errors you mentioned regarding return type - please use the code below:
public class getSingleRelatedList {
public List<Contact> listContactClientRecT{
get{listContactClientRecT = [Select Id,FirstName,LastName, RecordTypeId from Contact];
return listContactClientRecT;
}
set;}
public List<String> listRecordType {get; set;}
public String selectString {get; set;}
public ID accId {set; get;}
public getSingleRelatedList(ApexPages.StandardController controller) {
listRecordType = new List<String>();
listContactClientRecT = new List<Contact>();
accId = controller.getId();
}
public List<Contact> ClientRelatedList(){
listContactClientRecT = [Select Id,FirstName,LastName, RecordTypeId from Contact];
return listContactClientRecT;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
List<Contact> listContactRecTypeId =[Select RecordTypeId from contact where AccountId =: accId];
Set<ID> rectypeID = new Set<ID>();
for(Contact objContact : listContactRecTypeId ){
rectypeID.add(objContact.RecordTypeId);
}
if(listContactRecTypeId!=Null && !listContactRecTypeId.isEmpty())
for(ID objContact: rectypeID){
options.add(new SelectOption(objContact,objContact));
}
return options;
}
}
Currently the related list shows all contacts, please update the code to fit your requirement.