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
K SrikanthK Srikanth 

Can we hide custom tabs using APEX?

Hi,

Is there any way to hide custom tabs using APEX?
 
Abhishek BansalAbhishek Bansal
You can show the tab based on the permission set assignment and when you want to hide/remove this you can delete the permission set assignment record from apex.
It woould be good if you can share some more details.
AbhishekAbhishek (Salesforce Developers) 
Hide the tabs using Visualforce page:-

Sample Code:

<apex:page wizard="true">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >Name<apex:inputText /></apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton value="Store"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
</apex:page>


Output:

Output


For further reference, you can check this blog (http://Sample Code: <apex:page wizard="true"> <apex:form > <apex:pageBlock > <apex:pageBlockSection > <apex:pageBlockSectionItem >Name<apex:inputText /></apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Store"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>).

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks
K SrikanthK Srikanth
Hi ,

@Abhishek Bansal,

As you suggested, trying to assign permission sets through Apex.

When I checked first level, level one permission set should assign. when I checked second level, second one should get assign and previous one should get delete.

User-added image
 
@Abhishek,

Thanks for that, but I want to hide specific tab not all tabs.