Hide Tab based on UserGroup

I have a tab that I would like to hide based on a SharePoint user group called "admin".
How would I go about hiding this tab? Would I use css class with Javascript?

Hello @Alexander_Hunt,

You can either design a personalized form for admins and route to it based on user group. You can find more information create custom forms for users of different groups in our documentation here.

Or use the code to identify if the user is a member of the specific group and disable the tab:

fd.spRendered(function(){
    //replace "https://domain.sharepoint.com/sites/sitename/subsite" with path to your site
    let web = 'https://domain.sharepoint.com/sites/sitename/subsite';
    pnp.sp.web.currentUser.get().then(function(user){
            pnp.sp.web.siteUsers.getById(user.Id).groups.get().then(function(groupsData){
                    console.log(groupsData)
                    var groups = [];
                    //Check if the user is a member of the desired groups and add them to the array
                    for (var i = 0; i < groupsData.length; i++) {
                        if(groupsData[i].Title == 'Group Name') {
                            return true;
                        }
                    }
                }).then(function(isMember){
                    if(isMember){
                       //disable the second tab
                       fd.container('Tab1').tabs[1].disabled = true
                    }
                });
        });
});

The disabled tabs can be hidden by adding a CSS styling:

.tabset .disabled{
        display: none; /* hide disabled tabs */
}
1 Like

Hi @mnikitina ,
Is there a way to route a form based on user group in SharePoint 2019 on-premise? I only find reference to SPO in the documentation?
Also, are Form Sets available in SharePoint 2019 on-premise?
Thanks, Rhonda

@rhonda,

Yes, Form Sets are available for SharePoint On-Premises version and you can set up routing depending on user group(s) in the form set settings:

Hi @mnikitina,
I am receiving an error in the console: "Error: No custom routing defined." The error line is "..../plumsail/widget/sprouter.1.1.0.js:59". Must I include custom routing code if I only wish to display a specific FormSet based on the SharePoint groups that have been granted permission for that FormSet?

Also, on a similar topic, I added PlumSail forms and created FormSets to an older list which opens in Display mode from a link on the main listview. This list is on the same site as the one above, and I am using the same FormSet definitions (who gets to see which form). However, the FormSets are not being respected. My test user is seeing two different FormSets from the two lists. Both lists have the same SharePoint groups defined in the FormSets of each list. Is there something that I must do to have an old list work with FormSets. This old list was original created in Classic SharePoint.

Thanks, R

No, you don't need a code if you route only by user group.

Do you mean that this form is designed in Forms Designer?