Activity Forums Salesforce® Discussions How to conditionally hide field in Salesforce?

  • How to conditionally hide field in Salesforce?

    Posted by Ravi on July 13, 2018 at 12:51 pm

    Hello all,

    Need help for below requirement.

    In Case object I have one custom field(Text) say Description and have another field say Private(Checkbox).

    When user create any case and mark Private as Checked (Checkbox) then Description field should be visible to only the Owner of the case (creator of  the cecord) and the users who are upward in the role hierarchy, and other users won't be able to see this field.

    How we can achieve this? any idea?

    PS: I have already checked using Record type and different page layout.

    Thanks in advance, every help is appreciated.

     

    Shuvam replied 1 year, 4 months ago 5 Members · 4 Replies
  • 4 Replies
  • shariq

    Member
    September 12, 2018 at 6:09 pm

    Hi Ravi,

    You need to overwrite the standard detail page with custom visualforce page, where you can show/hide the field on custom logic in script.

    Hope this helps.

  • Parul

    Member
    September 13, 2018 at 4:18 am

    Hi

    I think you can't hide fields depending on values in other fields. Most user will set up a validation rule (VR) because Salesforce doesn't support this but if you to hide you can only do this by creating custom validation.

     

    Thanks

     

  • UTSAV

    Member
    June 12, 2023 at 5:31 pm

    Yes you can now make field to be visible conditionally on record page without using any custom component.
    Steps to follow:-
    Click on edit page on object record page > Click on Upgrade now as shown in below image.
    Then select your page layout and now you can see for each field edit icon is there, from there you can add the "set field visibility" filter based on other fields

  • Shuvam

    Member
    June 26, 2023 at 12:31 pm

    A common way to handle this is to use an additional field and a workflow rule or process builder to control the visibility. Here's a simple approach:

    1. Create another field, say "Private Description". This field should only be visible to the case owners and users above them in the role hierarchy.
    2. Create a workflow rule or a process in Process Builder. The rule should be such that when the 'Private' checkbox is checked, the content of 'Description' field should be copied over to 'Private Description' field and clear the 'Description' field.
    3. Similarly, when 'Private' is unchecked, copy the data back to the 'Description' field from 'Private Description' and clear 'Private Description'.

    This way, you can ensure that when 'Private' is checked, the 'Description' content is only visible in 'Private Description' field to the intended users. It does mean handling two fields instead of one, but it provides the visibility control you're looking for.

Log In to reply.

Popular Salesforce Blogs