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
RimaRima 

Visualforce to extend standard object layout

Hi All,

 

I want to know how to use Vsualforce to extend stanadrd object layout. For example, I want to add custom fields to contact object , and present these custom fields using Visualforce. I want to keep all the standard fields of contact as it is.Can I combine standard contact layout and Visualforce page? Any explanation on this is greatly appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Imran MohammedImran Mohammed

Yes you can do that.

What you have to do is first create all the custom fields.

Then goto Setup-->Customize-->Contacts-->Page Layouts.

Edit the page layout you want and add all the custom field you have created to the page layout.

 

Then do the following,

First of all to extend VF page to override an object detail page, the apex:page tag should be as below

<apex:page standardController="Contact" extensions="Your ExtensionClass">

</apex:page>

 

In the controller extension the constructor should look something like this,

For ex if class name contactExtension,

public Contact c {get;set;}

public ContactExtension(Apexpages.standardController sc)

{

c = (Contact)sc.getRecord();

}

 

The VF pageshould also include the apex:detail tag that will display all the standard fields along with custom field you created.

<apex:page standardController="Contact" extensions="Your ExtensionClass">

<apex:detail subject="{!c.id}"/>

</apex:page>

 

Then override the VF page for standard detail page.

goto Setup-->Customize-->Contacts-->Buttons and Links.

 

In Standard buttons and links section, click Edit link for View and select VF page you just created.

 

Let me know if you have any questions.

 

 

All Answers

Imran MohammedImran Mohammed

Yes you can do that.

What you have to do is first create all the custom fields.

Then goto Setup-->Customize-->Contacts-->Page Layouts.

Edit the page layout you want and add all the custom field you have created to the page layout.

 

Then do the following,

First of all to extend VF page to override an object detail page, the apex:page tag should be as below

<apex:page standardController="Contact" extensions="Your ExtensionClass">

</apex:page>

 

In the controller extension the constructor should look something like this,

For ex if class name contactExtension,

public Contact c {get;set;}

public ContactExtension(Apexpages.standardController sc)

{

c = (Contact)sc.getRecord();

}

 

The VF pageshould also include the apex:detail tag that will display all the standard fields along with custom field you created.

<apex:page standardController="Contact" extensions="Your ExtensionClass">

<apex:detail subject="{!c.id}"/>

</apex:page>

 

Then override the VF page for standard detail page.

goto Setup-->Customize-->Contacts-->Buttons and Links.

 

In Standard buttons and links section, click Edit link for View and select VF page you just created.

 

Let me know if you have any questions.

 

 

This was selected as the best answer
RimaRima

Thank you  for the explanation. I appreciate your help.

hezeheze

Hi ,

 

when I use:

 

<apex:detail subject="{!c.id}" title="true" />

 

I get a versoin of the standard page but not with the same look and feel as the original standard page, plus it doe sno tallow inline editing, if I use the option "inline" salesforce complains because seems that my version of the API does not support inline editing. Is there a way to replicate the standard layout in my overriding page so that it looks exactly the same?

 

thanks

madhunayaki2000@gmail.commadhunayaki2000@gmail.com

how to display the fields on visual force.

i insert the coding like.

<apex:page standardController="Account">
<apex:pageBlock title="My Account ">
<apex:pageBlockTable value="{! account.contacts}" var="item">
<apex:pageBlockSection title="Account.name">
<apex:pageBlockSectionItem dataStyle="Parent Account">
</apex:pageBlockSectionItem>>
</apex:pageBlockSection>
<apex:column value="{! item.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

 

but the fields not display what should i do.

 

thanks

madhu