I have a custom object that I wish to use the standard contact object so I do not need to reinvent the wheel by making my own Name, Address, Email etc fields. I made a master/detail on the custom object but contact just is a look up. That isn't intuitive. I want the field on the custom object layout (on top) so it looks like one form.

I would like this for standard salesforce interface and VFP. How to do this? Thanks.

  • Do you want to have the details page fields or edit page fields? For eg. Do you want Contact Name to be present on the custom object's record or Contact Name on the custom object create form? – Shailesh Patil Jan 23 '15 at 10:19

You can create the controller extension method where you can define one property contains the contacts of your current custom object contact matching id and there you can show all the fields using simple apex:pageBlock section like this

Visual Force page code

<apex:page standardController="customObjectName" extension="yourExtensionclass">
<apex:pageBlockSection value="{!contact}" columns="2" >
<!---Here you can populate all the required field as per your requirement as aq input field or output field --> 
<apex:inputField id="contactname" value="{!contact.Name}" label="Contact Name"/> 
<!--Here you can place your other designed code -->

Your Custom extension contoller class will be look like this

public class yourExtensionclass
    public final CustomObject customobject {get;private set;}
    //List will hold all your contact related information
    public Contact contact{get;set;}
    private ApexPages.StandardController mycontroller; 
    public yourExtensionclass(ApexPages.StandardController controller) 
       //Here you will get your lookup contact id 
       //By getting customobject.contact field
       List<Contact> contacts=new List<Contacts>();
       contacts=Database.query('Select Id,Name from contacts where id=\''+ customobject.contactfield + '\'\);
        contact= contacts.get(0);


Here customObjectName is the your custom controller name I had created contact object and used in visual force page. Hope it clearly solves your problem.


You may be interested in joining the pilot for Custom Person Object feature. See PM David Louie's comment on the IdeaExchange. https://success.salesforce.com/ideaView?id=08730000000BrapAAC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.