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
Jessica LandismanJessica Landisman 

How to hide Contact address with <apex:detail subject="{!contact.Id}" relatedList="false" />

I am creating a VisualForce page that displays a limited view of a Contact. I am using the call <apex:detail subject="{!contact.Id}" relatedList="false" title="true" /> , and this displays the Contact address, but I want to hide the Contact address.

 

Is there a way to display all fields of the Contact Detail except the address? Is there a way to set rendered="false" for a portion of the apex:detail (the address)?

 

I tried adding the following lines to the apex:page after the apex:detail mentioned above, but it had no impact on the display of the address.

 

      <apex:detail subject="{!contact.MailingStreet}" rendered="false" />
      <apex:detail subject="{!contact.MailingCity}" rendered="false" />
      <apex:detail subject="{!contact.MailingState}" rendered="false" />
      <apex:detail subject="{!contact.MailingPostalCode}" rendered="false" />
      <apex:detail subject="{!contact.MailingCountry}" rendered="false" />

 

Thanks,

Best Answer chosen by Admin (Salesforce Developers) 
Platy ITPlaty IT

Jessica,

 

You should have access to all of the custom fields in the field set, are you in Setup -> Customize -> Contact -> Field Sets?  There is no controller for field sets, nor do you need one.  Setting Contact as the standardController gives the page all of the methods associated with the Contact controller, like accessing the data from a Contact passed in with the "Id" parameter.  The field set just returns an ordered list of fields to the page.  

 

There's an example here you can basically just copy and paste for what you're doing, just replace "properNames" on the 3rd line with the name of the Field Set you create:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm

 

Jessie

 

All Answers

WizradWizrad

Detail tag is based off the page layout.  If you dont want those fields to appear remove them from the associated page layout.  If you want them to appear on the standard page and not on your visualforce page (e.g. changing the page layout is not an option) perhaps you could look into field sets, but there may be a hacky javascript way to remove them.

Jessica LandismanJessica Landisman

Wizrad,

   I want the address to appear in the Contact standard page layout. Can you recommend some documentation sources with regard to field sets? I am new to Salesforce development.

   Thanks,

Shashikant SharmaShashikant Sharma

The detail view will come according to your page layout for this profile user. Please remove these fields from layout if you want detail view not to conatin any fields. You can not put any condition in that. If you remove field level permissions for the user in that case also these field will not come in detail view.

If you don't want to update page layout or permissions then Using seperate output field in your Custom VFP is only option for you.

Platy ITPlaty IT

Jessica,

 

You'll need to specify which fields to display, which can either be hard-coded into the page itself or stored in a Field Set.  If you're new to VF, you might want to just start with hard-coding and you can always go back and update it with a Field Set when you get more advanced.  Make the StandardController of the page Contact (I suspect you already have) and the following code will do it, just add in whichever fields you need with outputField components as below.  The pageBlockSections divide up the page the same as sections in a regular page layout, so you can add additonal sections as needed.  

    <apex:pageBlock title="{!Contact.Name}" mode="maindetail">
        <apex:pageBlockSection title="Contact Information">
            <apex:outputField value="{!Contact.FirstName}"/>
            <apex:outputField value="{!Contact.LastName}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>

 

Jessica LandismanJessica Landisman

Jessie,

   Thanks for your helpful lead. I have 2 follow-on questions.

 

  1. If I want to use a Field Set, how do I include custom fields? I found the API name of each of those fields but did not see those customer fields in the Field-Set editor.

 

 2. Can you point me to some good documentation on how to leverage a Field Set?

 

    Thanks,

              Jessica

Jessica LandismanJessica Landisman

Jessie,

  Also, is there a means to include both a Field Set as the standard controller for one section of a VisualForce page and contact as the  standard controller for another portion of the same page?

Shashikant SharmaShashikant Sharma

For field Set you can see this example

 

http://forceschool.blogspot.com/2011/06/dynamic-binding-using-field-sets.html

 

Now the layout of field set editor is like page layout after summer 11 release.

Platy ITPlaty IT

Jessica,

 

You should have access to all of the custom fields in the field set, are you in Setup -> Customize -> Contact -> Field Sets?  There is no controller for field sets, nor do you need one.  Setting Contact as the standardController gives the page all of the methods associated with the Contact controller, like accessing the data from a Contact passed in with the "Id" parameter.  The field set just returns an ordered list of fields to the page.  

 

There's an example here you can basically just copy and paste for what you're doing, just replace "properNames" on the 3rd line with the name of the Field Set you create:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm

 

Jessie

 

This was selected as the best answer