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
Sam AlexSam Alex 

Show/Hide field in Standard Object (Accounts) depends on a field in Custom Object

Hi,

I have a field in Account object (which I have added). Lets say it is "Show_ID_in_acc". Every account has this check box.

Now I have a custom object called "Settings". In Settings object I have a check box called "Show_ID_in_settings". 

If I enable (check) the "Show_ID_in_settings" in my custom object I want to display the "Show_ID_in_acc" in Account detail page. If i uncheck the "Show_ID_in_settings", I dont want to see the "Show_ID_in_acc" in Account detail page.


It is like I have a Global switch in my custom object where I can turn off all "Show_ID_in_acc" in Account detail pages.


How can I do this?

Please help me.

Thanks in advance.
Best Answer chosen by Sam Alex
bob_buzzardbob_buzzard
In Visualforce you can conditionally render part of a page based on the contents of a field from an object known to the page/controller.  This doesn't impact the page layout for the sobject, rather you are replacing the page with your own coded version. This means that if an administrator wanted to add a field, they would have to come to you to change the code rather than using the page layout editor.  As I said, I wouldn't recommend it.

All Answers

bob_buzzardbob_buzzard
The bottom line is that you can't do this I'm afraid. You can only change standard page contents using the page layout editor. You'd need to Visualforce your account view pages to allow this kind of conditional behaviour (although I wouldn't recommend that).
Sam AlexSam Alex
Thanks for your response Bob. With Visualfoce, Apex, is it posible to do it? I mean to change the page layout on apex code to the field level of that object?
bob_buzzardbob_buzzard
In Visualforce you can conditionally render part of a page based on the contents of a field from an object known to the page/controller.  This doesn't impact the page layout for the sobject, rather you are replacing the page with your own coded version. This means that if an administrator wanted to add a field, they would have to come to you to change the code rather than using the page layout editor.  As I said, I wouldn't recommend it.
This was selected as the best answer
Sam AlexSam Alex
Ohhh... I got it. Means that its always better not to edit the layout with Apex since the users may have other sections or field in their view. Thanks Bob.