1

I want to hide/show few custom fields if a specific value is selected in one particular custom field. Is it possible?

2

No, it isn't possible out of the box. You might be able to do something with record types. You can have different page layouts for each record type, so you could set up a workflow rule that changes the record type based on the custom field. This has drawbacks because the user has to save the record before the field visibility changes.

Another option would be to override the standard page layouts with visualforce pages and have code on the page that hides and shows based on values.

  • How can I override standard page layout? Could you suggest any article? – Sanjivani Jun 28 '13 at 22:39
  • @Sanjivani My answer focuses more on an example of what Daniel was talking about at the last point. You can set the override at the custom object definition page (or standard object under "buttons, links and actions". You can set the override for each action (view, new, etc). One caveat, your VisualForce page has to use the standardController (see opening line of my example). For custom objects this is simply the name of the custom object (e.g. standardController="MyCustomObject__c") – drakored Jun 28 '13 at 22:45
2

Standard interface, not without changing the recordtype thereby changing the page layout. This is one of the biggest use cases for VisualForce that I see in my org. With VisualForce you can re-render the page with actionSupport tags, or from action tags. This allows the page (or parts of) to re-render and when combined with the rendered tag you can control whether items show up. Here is a very basic example you can use on Account that shows created date when the account name is set to "Test":

<apex:page standardController="Account">
  <apex:form id="myform">
    <apex:inputField value="{!Account.Name}">
      <apex:actionSupport event="onchange" rerender="myform"/>
    </apex:inputField>
    <apex:inputField value="{!Account.CreatedDate}" rendered="{!Account.Name='Test'}"/>
  </apex:form>
</apex:page>

The obvious downfall is that it requires you to build the page layout completely in VisualForce. Here is a great blog post from another developer with some ideas on how to work around this in standard layout.

http://pdespati.wordpress.com/2012/09/06/salesforce-dynamic-page-layout/

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.