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
manishtiwary1.390210540410199E12manishtiwary1.390210540410199E12 

Related List in VF page

Hi All,

I have created two object one is Prospect__c and Second is Lead_status__c
Also I have created a Visual force Page for Prospect__c.

Lead Staus is the child object for Prospect__c.

I want to show Lead_status__c as a related detials under Prospect__c visualforce page.

Below is the code I have wrtten .
But it is giving error"'Lead_status__c' is not a valid child relationship name for entity Prospect "

<apex:page standardController="Prospect__c"  cache="true" extensions="Convert" >

<br/><br/>
<apex:messages style="color:red; font-weight:bold; text-align:center;"/>

<apex:relatedList list="Lead_status__c" />

<apex:form >
<apex:pageBlock title="Prospects information"  >

<apex:pageBlockButtons >
<apex:commandButton value="Delete" action="{!delete}"/>
<apex:commandButton value="Edit" action="{!edit}"/>
<apex:commandButton value="Convert" action="{!convertbutton}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Prospects Details" columns="2">
<apex:outputField value="{!Prospect__c.Salutation__c}"/>
<apex:outputField value="{!Prospect__c.First_Name__c}"/>
<apex:outputField value="{!Prospect__c.Name}"/>
<apex:outputField value="{!Prospect__c.Ownerid}"/>
<apex:outputField value="{!Prospect__c.Title__c}"/>
<apex:outputField value="{!Prospect__c.Website__c}"/>
<apex:outputField value="{!Prospect__c.Company__c}"/>
<apex:outputField value="{!Prospect__c.Rating__c}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title="Address and Contact Information">
<apex:outputField value="{!Prospect__c.Street__c}"/>
<apex:outputField value="{!Prospect__c.Email__c}"/>
<apex:outputField value="{!Prospect__c.City__c}"/>
<apex:outputField value="{!Prospect__c.Phone__c}"/>
<apex:outputField value="{!Prospect__c.State__c}"/>
<apex:outputField value="{!Prospect__c.Mobile__c}"/>
<apex:outputField value="{!Prospect__c.Pin__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Lead Source Information" columns="2">
<apex:outputField value="{!Prospect__c.Lead_Source__c}"/>
<apex:outputField value="{!Prospect__c.Promotion__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Lead Processing Information" columns="2">
<apex:outputField value="{!Prospect__c.Lead_Status__c}"/>
<apex:outputField value="{!Prospect__c.Do_Not_Call__c}"/>
<apex:outputField value="{!Prospect__c.Industry__c}"/>
<apex:outputField value="{!Prospect__c.Email_Opt_Out__c}"/>
<apex:outputField value="{!Prospect__c.No_of_Employees__c}"/>
<apex:outputField value="{!Prospect__c.Annual_Revenue__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description" columns="2">
<apex:outputField value="{!Prospect__c.Description__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:commandLink value="Redirect to Site" style="color:blue; font-weight:bold;" action="{!RedirecttoSite}"/>
</apex:form>
</apex:page>
SarfarajSarfaraj
Hi Manish

Please use child relationship name instead of child object name. Usually child relationship name is <plural name>__r for custom objects. If your child relationship name is Lead_status__r you have to write.
<apex:relatedList list="Lead_status__r" />
You may verify your child relationship name from workbench. Below is an example for child relationship contact in account object. Please check the same for your Prospect__c object.

User-added image

KoenVMKoenVM
hi,

Instead of using the name of the object in the apex:relatedList, you need to use the "Child Relationship Name".
So on your Lead_status__c object, you will probably have a master-detail to the Prospect object.
Go on that master-detail field and there you will find the "Child Relationship Name".
Use that in your relatedList.

See this screenshot:
User-added image
manishtiwary1.390210540410199E12manishtiwary1.390210540410199E12
Thank you both of you.It is working now. Thank you for your help.
manishtiwary1.390210540410199E12manishtiwary1.390210540410199E12
Now on the same visual force page i want to display a list button?? How we can achive this
SarfarajSarfaraj
Can you please elaborate your requirement?