3

I would like to Show a field in page layout Based on Status. "Approved date"(Date data type) field to track when Status is set to "Yes" or
"Rejected Date" field to track when Status is set to "No"

Uwe Heim
  • 28,350
  • 18
  • 115
  • 283
user5257
  • 363
  • 5
  • 14

1 Answers1

2

With the declarative approaches you will have only the limited options supported by dependent picklist to hide and show fields dynamically: https://help.salesforce.com/HTViewHelpDoc?id=fields_dependent_field_considerations.htm&language=en_US

So for you use case it's possibly not sufficient.

An other very bulky approach, would be to achieve this with Record-Types, different Layouts and a Workflow to switch the Record-Type according to the Status value. It is conceptually covered in this video: https://www.youtube.com/watch?v=TyVNS0M02w4

Personally I think the UX will be not perfect in your case, because you would have to change the value, then press save and then after a page-reload you finally get the updated UI. One or two clicks to much for my taste, but I'm very picky!

So I would prefer to override the View/Edit with a visualforce page, get the base layout with <apex:detail> and use JS and jquery to make it happen dynamically. To figure out the right Id for your selectors could be a challenge, but therefore you could have a look at this article: http://andyinthecloud.com/2014/01/05/querying-custom-object-and-field-ids-via-tooling-api/

If you are not afraid of leaving the path of the bushido, you could also have a look at this posting to hook in some custom JS into your standard page layout without the need of a visualforce override: End of javascript sidebar workarounds? But you should keep in mind that salesforce may stop this approach from working some time in the future.

Uwe Heim
  • 28,350
  • 18
  • 115
  • 283