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
jyovasjyovas 

how do filter data in related list ?

What is the best way to filter data in related list? I want to filter records in Contact related list in Account page with certain recod types.

 

The requirement is when certain type of user is logged in he should see the contact records of a specific recordtype in account page contact related list.

 

Thanks in advance

-John

hisrinuhisrinu

You can make use of rendered attribute as below.

 

 

rendered="{!c.recordtype = 'give the recordtype id'}">

 

 

else you can query those records and display them in a page block table

jyovasjyovas

We can do this only if we customize Account page and write our own VF page ,  correct ? Is it possible without rewriting the page ?

 

Thanks

-John

hisrinuhisrinu

No you have write in VF page... you can make use of apex:detail tag which gives you the same look and feel of vanila page then modify the desired related list.

jyovasjyovas

Srini thanks for the prompt reply

I am able to recreate the detail page with apex:detail tag

 

Now how do I achive this

rendered="{!c.recordtype = 'give the recordtype id'}">

where does c come from ?  do i have to write a extention controller as well ?

 

Could you please show me a usage of it or a reference to a usage?

 

I am very new to VF & apex

 

Thanks,

John

hisrinuhisrinu

Here is the sample code

 

 

<apex:pageblock>
<apex:pageblocktable value = "{!account.contacts}" var = "c">
<apex:column value = "{!c.lastName}"rendered="{!c.recordtype = 'give the recordtype id'}"/>
</apex:pageblocktable>
</apex:pageblock>

 

 

jyovasjyovas

Srini thanks a lot for your guidance

 

Right now I have

 

<apex:page standardController="Account">
<apex:detail />
<apex:pageBlock >
<apex:pageblocktable value="{!account.contacts}" var="c">
<apex:relatedList subject="{!account}" list="Contacts" pageSize="20" rendered="{!c.RecordTypeId ='012A0000000PRXW'}"/>
</apex:pageblocktable>
</apex:pageBlock>
</apex:page>

 

With this its not filtering the contacts of recordtypeid  012A0000000PRXW in related list . I am able to see contacts with other recordtype ids.

Thanks,

John

hisrinuhisrinu

Here you should not use the relatedlist tag as is... you have to specify the fields as below.

 

<apex:pageblock>
<apex:pageblocktable value = "{!account.contacts}" var = "c">
<apex:column value = "{!c.lastName}"rendered="{!c.recordtype = 'give the recordtype id'}"/>
<apex:column value = "{!c.FirstName}"rendered="{!c.recordtype = 'give the recordtype id'}"/>
<apex:column value = "{!c.title}"rendered="{!c.recordtype = 'give the recordtype id'}"/>
//specify all other fields here
</apex:pageblocktable>
</apex:pageblock>
jyovasjyovas

I was not able to get this work . So I had to do it with a controller code and filter the contacts there before rendering it on relatedlist with pageblocktable....

sfadminsssfadminss

Can you show me how you accomplished this?  I would like to filter the contact list that displays to not include contact that have a contact status of No longer with company.