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
bs881026bs881026 

How to make a Tab visible and invisible for a User

HI, I have a scenario, where I need to make a Tab visible or insible for Users, based on a checkbox checked for that User.
Kindly help me achieve this.
Sumit Kumar Singh 9Sumit Kumar Singh 9

Can't you do it with profiles?
If there are more than one user with the same profile then, hide the tab for all users. Use 'permission set' to grant access to the users you want.

Thanks,
Sumit Kumar Singh

bs881026bs881026
I didnt get my answer, can you please be more elaborative.Permission sets I know, but how to accomplish this scenario exactly.
Sumit Kumar Singh 9Sumit Kumar Singh 9

You can hide/show tabs direclty from the profiles. But, can can have scenario that one profile can be assigned to multiple users. In that scenario do the following-

1) Creae a permission set let's say "Access to tabs" and make the tab visible inside the permission set.
2) Assign that permission set to the user to whom you want to make the tab visible.

No, need to use checkbox. You can do it with the out of box salesforce functionality. Hope, it will help you.

Thanks,
Sumit Kumar Singh

bs881026bs881026
I have to use the checkbox. My requirement is that as an Admin, I need to allow and disallow Users based on a checkbox, if the checkbox for that User is checked, that user will be able to see the Account record else not.
Sumit Kumar Singh 9Sumit Kumar Singh 9
Bro,
I think  that can also be done with salesforce out of the box functionlity using "sharing settings". YOu  are trying to do redudant work using code, which is already availe in salesforce.
I don't think that you can hide/show tab, the way you are trying.

Thanks,
Sumit Kumar Singh
bs881026bs881026
Sharing settings define the visibility of the records.
Jancy MaryJancy Mary
Interesting question :-)

My inputs,
- This is the point where you have to think completely on Salesforce side being a Salesforce Admin or Developer, any requirement on salesforce come in your way first you have to think if it is possible through standard functionality.

Salesforce mainly concentrates to bring all building functionalities without coding, that way any user who run their business using Salesforce should be able to achieve all business logic requirements with the help of their system administrators with the standard functionalities available already in there like WF rules, process builder, profiles, roles, sharing rules & others.

In your scenario no need to think of hard code, keep it simple by using standard functionality (just a click path), don't make your org feel heavy to run by hard coding maximum requirements when you can achieve them with standard functionality. 
 
For your requirement resolution is:
-Profile is one way to grant or restrict access to Objects, Tabs etc. (choose this when you want to open up or restrict the access for all users under this profile)
-Permission set is the other way to open up the access to Objects, Tabs etc. (choose permission set if you want to open up the access to a specific user while the Tab is hidden on profile level). You can then assign the permission set to the users whom you want to open up the access.

article for your reference:
http://help.salesforce.com/HTViewHelpDoc?id=users_tab_visibility.htm

Thanks,
bs881026bs881026
How to manage the visibility of the tab on the click of checkbox ?
Todd GillTodd Gill
If you must handle this use case as described, where the visibility of a tab must be controlled by a checkbox field on the User sObject, then I would suggest:

1. Create a permission set that provides visibility to the tab, and
2. Create an Apex trigger on the User sObject.  This trigger will simply assign or un-assign the permission set to a User based on the value of the the checkbox field.