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
Chitral ChaddaChitral Chadda 

how to hide related list

<apex:page standardController="Contact"  >
<apex:detail relatedList="false">

<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockSection >
<apex:inputField value="{! contact.accountid}"/>
<apex:inputField value="{! contact.phone}"/>
<apex:inputField value="{! contact.FirstName}"/>
<apex:inputField value="{! contact.LastName}"/>
<apex:inputField value="{! contact.Fax}"/>
<apex:inputField value="{! contact.Email}"/>
<apex:inputField value="{! contact.title}"/>
<apex:inputField value="{! contact.phone}"/>

<apex:inputField value="{! contact.HomePhone}"/>
<apex:inputField value="{! contact.Department}"/>
<apex:inputField value="{! contact.Birthdate}"/>
<apex:inputField value="{! contact.MobilePhone}"/>



<apex:commandButton action="{! save }" value="save"/>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

when i save the contact it shows related list like cases, opportunity etcc..
i dont want the related list to come i hv put the tag for it but its still showing related list
Jen BennettJen Bennett
After you hit save are you going back to the standard Contact page? This page appears to be used to override the edit page, but you would either need to override the view page or have the save take you to a custom visualforce page. You can ovveride the save button(extension) or setting the saveURL paramemeter in the URL should work as well.
Sai Ram ASai Ram A
Hello Chitral Chadda

Your Code Shows that you are in New or Edit page, where Related lists are visible only on Detail page
Use below Code and Override View Button

<apex:page standardController="Contact">
   <apex:detail subject="{!Contact.Id}" relatedList="false" title="false"/>
</apex:page>

If this post is helpful please throw Kudos.
If this post solves your problem kindly mark it as solution.
Virendra ChouhanVirendra Chouhan
Hi Chitral,

Both above answers are right.
you are using the standard Save action so after clicking on it it'll jump on the standard detail page and their all related list are true.

so have to use Quicksave  action because this action stay on this page.
and use the code which  BLearn write above >

i.e 
<apex:page standardController="Contact">
            
       <apex:detail subject="{!Contact.Id}" relatedList="false" title="false"/>

<apex:form >
    <apex:pageBlock >
            <apex:pageMessages />
                <apex:pageBlockSection rendered="{!IF((Contact.id == null),true,false)}">
                        <apex:inputField value="{! contact.accountid}"/>
                        <apex:inputField value="{! contact.phone}"/>
                        <apex:inputField value="{! contact.FirstName}"/>
                        <apex:inputField value="{! contact.LastName}"/>
                        <apex:inputField value="{! contact.Fax}"/>
                        <apex:inputField value="{! contact.Email}"/>
                        <apex:inputField value="{! contact.title}"/>
                        <apex:inputField value="{! contact.phone}"/>
        
                        <apex:inputField value="{! contact.HomePhone}"/>
                        <apex:inputField value="{! contact.Department}"/>
                        <apex:inputField value="{! contact.Birthdate}"/>
                        <apex:inputField value="{! contact.MobilePhone}"/>
        
                        <apex:commandButton action="{! quicksave }" value="save"/>

        </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>