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
Sravanthi SunkariSravanthi Sunkari 

how to make a field visible only on edit page but not on detail page

Hi, Can anyone suggest me how to make a custom field(Data Type Number) on Account object editable on creat/edit page but hidden on detail page once record is saved.
From previous question & answers I understand that it is possible only through VF page to override the settings. Can someone explain how this can be done eithr standerd if possible otherwise if not through VF page in detail. ( I am new to programming, a sample of code will be appreciated)
Best Answer chosen by Sravanthi Sunkari
Abhishek BansalAbhishek Bansal
Hi, 

In order to hide any field only from detail page of Account you have to create a custom VF page on Account and override the view button of Account with this VF page.

I am providind you a sample code of VF page :
 
<apex:page standardController="Account" ">
	<apex:pageBlock>
		<apex:pageBlockButtons >
    		<apex:commandButton action="{!edit}" value="Edit"/>            
             <apex:commandButton action="{!delet}" value="Delete"/>
    		<apex:commandButton action="{!cancel}" value="Cancel"/>
    	</apex:pageBlockButtons>
    	<apex:pageBlockSection columns="2" title="Account Information">
	    	<apex:inputField value="{!Account.Name}" />
		    <apex:inputField value="{!Account.AccountNumber}"/>
	    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
The fields which you will add in the pageBlockSection will. be visible on the Account detail page.
So you can customize this page according to your requirement and do not add the field which you want to hide.

Please let me know if you need more help on this.

Regards,
Abhishek

All Answers

Abhishek BansalAbhishek Bansal
Hi, 

In order to hide any field only from detail page of Account you have to create a custom VF page on Account and override the view button of Account with this VF page.

I am providind you a sample code of VF page :
 
<apex:page standardController="Account" ">
	<apex:pageBlock>
		<apex:pageBlockButtons >
    		<apex:commandButton action="{!edit}" value="Edit"/>            
             <apex:commandButton action="{!delet}" value="Delete"/>
    		<apex:commandButton action="{!cancel}" value="Cancel"/>
    	</apex:pageBlockButtons>
    	<apex:pageBlockSection columns="2" title="Account Information">
	    	<apex:inputField value="{!Account.Name}" />
		    <apex:inputField value="{!Account.AccountNumber}"/>
	    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
The fields which you will add in the pageBlockSection will. be visible on the Account detail page.
So you can customize this page according to your requirement and do not add the field which you want to hide.

Please let me know if you need more help on this.

Regards,
Abhishek
This was selected as the best answer
Amit Chaudhary 8Amit Chaudhary 8
You can override the Detail page. Please check below post

Overriding Standard Buttons and Tab Home Pages
https://help.salesforce.com/HTViewHelpDoc?id=links_customize_override.htm
https://help.salesforce.com/HTViewHelpDoc?id=links_override_considerations.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=links_override_considerations.htm&language=en_US)
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_tabs.htm

You can see below vedio for step by step process
https://www.youtube.com/watch?v=kiCbsoOF6so

Override standard Links with VisualForce pages in Salesforce
http://www.jitendrazaa.com/blog/salesforce/override-standard-links-with-visualforce-pages-in-salesforce/

Pleae let us know if this will help you

Thanks
Amit Chaudhary
 
Sravanthi SunkariSravanthi Sunkari
Hi Abhishek and Amit,
Thanks for your replies and help.
Both of your answers helped me to solve my problem. I might have not been able to do it without one another.
As I had to choose only one best answer, I had to choose the first one(Abhishek's) which gave me detailed understanding of the code.

I alterd the code little bit as the above code resulted in some minor errors.

<apex:page standardController="Account">
<apex:sectionHeader title="Account Detail"/>
<apex:form >
 <apex:pageBlock >
   <apex:pageBlockButtons >
      <apex:commandButton action="{!edit}" value="Edit"/>           
      <apex:commandButton action="{!delete}" value="Delete"/>
      <apex:commandButton action="{!cancel}" value="Cancel"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection columns="2" title="Account Information">
      <apex:outputField value="{!Account.Name}" />
      <apex:outputField value="{!Account.AccountNumber}"/>
      <apex:outputField value="{!Account.Fax}"/>
      
      </apex:pageBlockSection>
 </apex:pageBlock>
</apex:form> 
</apex:page>


This is my first code I had ever created on my own in salesforce to resolve the issue. Thanks to the community for giving me a chance to learn something new  today without much hassels to face.
Sravanthi SunkariSravanthi Sunkari
Hi,
I received the  fallowing error when I tried to add a Hirarchy field Parent Account

Expression value does not resolve to a field
Error is in expression '{!Account.Parent}' in component <apex:outputField> in page


thanks
Sravanthi SunkariSravanthi Sunkari
I also have another doubt, In my Account object we have different page layouts for different profiles.
I am working on Sales user profile pagelayout currently . Does overriding with VF page effect the detail pages of other profiles or the record types of same profile.
Thanks.
Abhishek BansalAbhishek Bansal
Hi,

Answering your first question : Please use the API name of Parent field. I think you have custom field on Account object as Parent so please use its API name like Parent__c.

Secomd Question : If you override a standard detail page than it will effect all the page layouts and record types also.

Thanks,
Abhishek.