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
Sahil Mahajan 32Sahil Mahajan 32 

How to query Users who have access to a particular Tab ?

My use case is - I want list of all Users who have access to a particular Custom Tab. 
VinayVinay (Salesforce Developers) 
Hi Sahil,

In Apex, you can check only Object/Field permissions and not tab visibility. To do that, we need to use Metadata API.

Check below references.

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profiletabvisibility_title
https://salesforce.stackexchange.com/questions/49270/how-to-get-custom-tab-visibility-in-controller-based-on-user-profile

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
J PaulJ Paul

You could query the PermissionSetTabSetting object to get a list of which Profiles/Permission Sets have the particular tab access you're interested in. Then query the PermIssionSetAssignment object to determine which users are assigned.

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_permissionsettabsetting.htm

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_permissionsetassignment.htm