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
TSKRTSKR 

Hide Field from Edit Page of CUstom Object but available in Detail Page

Hello All,

 

I have a requirement where I want to hide some fields from Edit layout of an object , while I want to display them in Detail Page. These fields will be populated by Trigger, but user should also have option to Edit some of the values if needed.

 

Thanks in Advance.

Ashish_SFDCAshish_SFDC

Hi TSKR, 

 

You have to create a Visualforce Edit page without that field(s) and override the Existing one. 

See a related post: http://boards.developerforce.com/t5/Visualforce-Development/hiding-a-field-in-pagelayout/td-p/135123

 

Regards,

Ashish

VennilaVennila

Hi,

 

You have to achieve this logic through Visualforce Page and Apex controller. 

 

Please take a look in this Visualforce page and controller, It may be helpful for you.

 

Visualforce Page

 

<apex:page standardcontroller="Lead" extensions="demovf">
<apex:pagemessages />
<apex:form >
<apex:pageblock rendered="{!flag==false}">
<apex:pageblocksection columns="1">
<apex:inputField value="{!Lead.Company}" />
<apex:inputField value="{!Lead.LastName}" />
<apex:inputField value="{!lead.status}"/>
<apex:inputField value="{!lead.leadsource}" rendered="{!display==true}"/>
<apex:commandbutton action="{!Save}" value="Save" />
</apex:pageblocksection>
</apex:pageblock>

<apex:pageblock rendered="{!flag==true}">
<apex:pageblocksection columns="1">
<apex:Commandbutton value="Edit1" action="{!Edit1}" />
<apex:outputField value="{!Lead.Company}" />
<apex:outputField value="{!Lead.LastName}" />
<apex:outputField value="{!lead.status}"/>
<apex:outputField value="{!lead.leadsource}" />

</apex:pageblocksection>
</apex:pageblock>


</apex:form>
</apex:page>

 

Apex controller:

 

public with sharing class demovf {

public lead l{get;set;}
public boolean flag{get;set;}
public boolean display{get;set;}
public demovf(ApexPages.StandardController controller) {
l=(Lead)controller.getRecord();

}
public void save()
{
insert l;
flag=true;
}
public void edit()
{
}
public void edit1()
{
flag=false;
display=true;
}

}

 

In this program, Lead Source field will not display while creating a new record. But this field display in the detail page. While editing this record, that Lead Source will be available. 

VIMAL SRIVASTAVA.ax1855VIMAL SRIVASTAVA.ax1855

Hello TSKR

you dont need to create VF page for this, Just create an alternate formula field for all you want to hide and palce them on the layout.

populate the fromula fields with the values of original ones.

 

Hope this works.

 

Regard

VIMAL SRIVASTAVA 

Padma rudraPadma rudra
@ Vimal
How to hide the formula filed on edit page and display it only on detail page?When i add formula filed to layout then its displaying in edit page as well!!