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
PedroLPedroL 

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

Rajesh ShahRajesh Shah
I assume you are using PageBlockTable to display the related list since you are filtering it. In that case, as far as I know, you would have to write code for each of the functionality like adding button, edit, del link, etc. But if you want to do it for one of the related list, I would remove the related list from page layout, have related list = true for detail tag and display the custom related list using pageBlockTable.
Message Edited by Rajesh Shah on 02-12-2010 12:05 PM
PedroLPedroL

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];   
    }
}

Gerry SGerry S

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.