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
Abhilash Gupta 10Abhilash Gupta 10 

To Display the Tab Settings Permission in a VF Page

Hi All,

How to get the Tab Settings(Default on,Default off,Tab Hidden) of all the Profile in a Vf Page?


Regards
Abhilash
Ajay K DubediAjay K Dubedi
Hi Abhillash,
Create a permission Set : Setup -> Manage Users -> Permission Set -> New
Label – Tab Permissions
API Name – Tab_Permissions
User License – Salesforce
Create apex class:
public with sharing class tabs{
public list<PermissionSetAssignment> perset{get;set;}
public tabs(){
perset=[SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId =:UserInfo.getUserId() AND PermissionSet.Name like ‘%Tab_Permissions%’ limit 1];
}
Create a Page:
<apex:page controller=”tabs” id=”page”>
<apex:tabPanel switchType=”client” >
<apex:tab label=”One” ></apex:tab>
<apex:tab label=”Two” ></apex:tab>
<apex:tab label=”Three” rendered=”{!perset.size!=0}” ></apex:tab>
<apex:tab label=”Four” ></apex:tab>
<apex:tab label=”Five” ></apex:tab>
</apex:tabPanel>
</apex:page>
In the above code we have used render attribute in the <apex:tab>, so the third tab will not be visible to the current user. Now assign the newly created permission set “Tab permission” to the logged in user and refresh the page, It will be displayed in the page now.
To assign permission set:
Setup-> Manage Users-> Permission sets-> “Tab permissions” -> Manage permissions -> Add assignments -> check required users -> Assign.
This is one of the ways that we can control the visibility of any of the tab in a Visualforce page using apex.

Thanks.
Abhilash Gupta 10Abhilash Gupta 10
Hi Ajay,

My Requirement is:
I have 2 picklist field   a)  Profile 1  b) Profile 2
After selecting  these two ,I want to display the Tabs setting Permission in a VF page related to those two Profiles.

For Ex: If i select Profile 1="Sys Admin" and Profile 2="Read Only " then it should display:
Accounts: Default On                                               Accounts: Default Off                                                 
Price Books Default Off                                            Leads Default On
Console Tab Hidden                                                 Opportunity:Default On...
Contacts Default On...and so on

Regards
Abhilash