You need to sign in to do that
Don't have an account?
Filtering a Related List
Hello,
I'm trying to reproduce the same functionality I would have with a related list selected on a page layout but filtering the values that actually make up the list. I have found some examples for creating such a list using extensions for the standard controller. I have been able to create and filter the list but I'm missing some functionality such as: (1) the buttons that are usually displayed next to the title of the list, (2) the icon next to the title of the list and (3) the option to display the selection boxex next to each item on the list for multi-record actions.
Is it possible to expose this functionality without writing a whole lot of code?
Thanks,
Pedro
Hello,
Yes, I'm using the PageBlockTable to display the realted list. I guess what I'm missing is a way to place the standard buttons used for the related object since the controller that is being referenced in my Visaulforce page corresponds to the master object.
I'm referencing the new method for Contacs in the button but that gives me the following error:
Illegal view ID {Contact.New}. The ID must begin with /
The logic is already implemented for the standard controller, I assume there must be a way to access it without wrinting the code for the button.
Thanks,
Pedro
This is the code for the Visualforce page
<apex:page standardController="Account" extensions="accountContactExt">
<apex:relatedList list="Contacts"/>
<apex:form >
<apex:pageBlock tabStyle="Contact" title="Sales Contacts sorted By Title and Name">
<apex:pageBlockButtons >
<apex:commandButton action="{Contact.New}" value="New"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!salescontacts}" var="c">
<apex:column headerValue="Action">
<apex:outputLink value="{!URLFOR($Action.Contact.Edit,c.id)}">Edit</apex:outputLink>
<apex:outputLabel value=" | "/>
<apex:outputLink value="{!URLFOR($Action.Contact.Delete,c.id)}">Del</apex:outputLink>
</apex:column>
<apex:column headerValue="Contact Name">
<apex:outputLink value="{!URLFOR($Action.Contact.View,c.id)}">{!c.name}</apex:outputLink>
</apex:column>
<apex:column headerValue="Title" value="{!c.title}"/>
<apex:column headervalue="Email">
<apex:outputField value="{!c.email}"/>
</apex:column>
<apex:column headerValue="Phone" value="{!c.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
This is the code for the Controller extension
public class accountContactExt {
Account a;
public accountContactExt(ApexPages.StandardController controller) {
a = (Account) controller.getRecord();
}
public List<Contact> getSalesContacts() {
return [select name, title, email, phone from contact where accountid = :a.id and phone <> '' order by title, name];
}
}
You probably have found it by now, but also for other people reading this, the problem is found in the commandbutton.
<apex:pageBlockButtons >
<apex:commandButton action="{Contact.New}" value="New"/>
</apex:pageBlockButtons>
replace with {!$Contact.New} and I think it would work.