Skip to main content

SharePoint 2013/Project Server 2013 - Remove or hide ribbon button

SharePoint/Project Server - Remove or hide ribbon button

SharePoint and Project Server has a lot of functionality in the ribbon. Sometimes it can be beneficial to hide some of the buttons for the users so they do not get too confused.

The correct way to hide ribbon buttons is to create a SharePoint feature in Visual Studio and create some XML to override the ribbon. However, if you are not that familiar with developing or Visual Studio it can be a prohibitive task to do.
If you would like to go with the feature solution here is a link for a nice guide on how to do it: http://msdn.microsoft.com/en-us/library/office/ff408060(v=office.14).aspx

In this post I will go through how to remove ribbon buttons only through the standard Script Editor webpart and Javascript. However you don’t have to know Javascript to complete the task.
The downside of this approach is that your have to add the webpart on all pages where you want to remove the ribbon.

Remove Ribbon Buttons

In Project Server on a PDP page lets say you have a ribbon which looks like this:

(click on image for better quality)

Now in this PWA instance we do not have any Project Sites and they are also disabled in PWA Settings. Therefore, we want to remove the Project Sites button from the ribbon and the Quick Launch. We would also like to remove the Documents, Issues and Risks links.
To do this go to the PDP site and add a new Script Editor webpart.
(click on image for better quality)

In the script editor webpart click EDIT SNIPPET and add the following javascript code:

<script>
    function removeLinks() {
        try {
            var elements = null;
            try {
                elements = document.getElementsByClassName('static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode')
            } catch (ex) {
                //IE8 and lower
                elements = document.querySelectorAll('.static.menu-item.ms-core-listMenu-item.ms-displayInline.ms-navedit-linkNode');
            }
            for (i = 0; i < elements.length; i++) {
                var elm = elements[i];
                if (elm.innerHTML.indexOf('Project Site') >= 0) {
                    elm.style.display = 'none';
                }
            }
            var ribbonBtn = document.getElementById("Ribbon.Tabs.PDP.Home.GoTo-Large-2-1");
            ribbonBtn.style.display = 'none';
            ribbonBtn = document.getElementById("Ribbon.Tabs.PDP.Home.GoTo.GoToDocuments-Medium");
            ribbonBtn.style.display = 'none';
            ribbonBtn = document.getElementById("Ribbon.Tabs.PDP.Home.GoTo-Large-2-2");
            ribbonBtn.style.display = 'none';
            ribbonBtn = document.getElementById("Ribbon.Tabs.PDP.Home.GoTo.GoToWorkspace-Large");
            ribbonBtn.style.display = 'none';
        } catch (ex) { }
        setTimeout(removeLinks, 500);
    }
removeLinks();

</script>

Script Editor webpart:
(click on image for better quality)

Click Insert and click Stop Editing.
Now the buttons for the project site will be hidden.
(click on image for better quality)

Remember you have to do this for all pages or PDP’s where the buttons should be removed.

Hiding other buttons

If you want to remove other buttons simply replace the button id in the Javascript with the button you want to remove.

<script>
    function removeLinks() {
        try {
            
            var ribbonBtn = document.getElementById("Ribbon.Tabs.PDP.Home.GoTo-Large-2-1");
            ribbonBtn.style.display = 'none';         
        } catch (ex) { }
        setTimeout(removeLinks, 500);
    }
removeLinks();

</script>

There are many ways of finding the button id, but I find the easiest way is to use Firefox and Firebug.
(click on image for better quality)

Below i have listed the most common ID's used in the PWA. 
The ID's are listed in the same order as the buttons are placed in the ribbon (starting from the left). 

(click on image for better quality)
Ribbon.ContextualTabs.ProjectCenter.Home.Editing
-        Ribbon.ContextualTabs.ProjectCenter.Home.Editing.NewProject-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.Editing.OpenProject-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.Editing.Import-Large
Ribbon.ContextualTabs.ProjectCenter.Home.GoTo
-        Ribbon.ContextualTabs.ProjectCenter.Home.GoTo-LargeLarge-0
o   Ribbon.ContextualTabs.ProjectCenter.Home.GoTo.GoToTeamBuilder-Large
o   Ribbon.ContextualTabs.ProjectCenter.Home.GoTo.GoToResourcePlan-Large
o   Ribbon.ContextualTabs.ProjectCenter.Home.GoTo.GoToProjectPermissions-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.GoTo-LargeLarge-1
o   Ribbon.ContextualTabs.ProjectCenter.Home.GoTo.GoToCheckin-Large
Ribbon.ContextualTabs.ProjectCenter.Home.Navigate
-        Ribbon.ContextualTabs.ProjectCenter.Home.Navigate.ZoomIn-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.Navigate.ZoomOut-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.Navigate.ScrollTask-Large
Ribbon.ContextualTabs.ProjectCenter.Home.Data
-        Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-0
-        Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-1 (icons)
o   Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-1-0
o   Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-1-1
o   Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-1-2
-        Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-2 (dropdowns)
o   Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-2-0
o   Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-2-1
o   Ribbon.ContextualTabs.ProjectCenter.Home.Data-Large-2-2
Ribbon.ContextualTabs.ProjectCenter.Home.Timeline
-        Ribbon.ContextualTabs.ProjectCenter.Home.Timeline.AddProject-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.Timeline.AddTasks-Large
Ribbon.ContextualTabs.ProjectCenter.Home.Share
-        Ribbon.ContextualTabs.ProjectCenter.Home.Share.ExportExcel-Large
-        Ribbon.ContextualTabs.ProjectCenter.Home.Share.Print-Large
Ribbon.ContextualTabs.ProjectCenter.Home.ShowHide
-        Ribbon.ContextualTabs.ProjectCenter.Home.ShowHide-Large-0-0
-        Ribbon.ContextualTabs.ProjectCenter.Home.ShowHide-Large-0-1
Ribbon.ContextualTabs.ProjectCenter.Home.ChangeProjectType
Ribbon.ContextualTabs.ProjectCenter.Home.Publish
Ribbon.ContextualTabs.ProjectCenter.Home.Publish

(click on image for better quality)
Ribbon.Tabs.PDP.Home.Project
-        Ribbon.Tabs.PDP.Home.Project.Edit-Large
-        Ribbon.Tabs.PDP.Home.Project.Save-Large
-        Ribbon.Tabs.PDP.Home.Project.Close-Large
Ribbon.Tabs.PDP.Home.GoTo
-        Ribbon.Tabs.PDP.Home.GoTo-Large-0
-        Ribbon.Tabs.PDP.Home.GoTo-Large-1
-        Ribbon.Tabs.PDP.Home.GoTo-Large-2
o   Ribbon.Tabs.PDP.Home.GoTo-Large-2-0
o   Ribbon.Tabs.PDP.Home.GoTo-Large-2-1
o   Ribbon.Tabs.PDP.Home.GoTo-Large-2-2
-        Ribbon.Tabs.PDP.Home.GoTo-Large-3
o   Ribbon.Tabs.PDP.Home.GoTo-Large-3-0
o   Ribbon.Tabs.PDP.Home.GoTo-Large-3-1
o   Ribbon.Tabs.PDP.Home.GoTo-Large-3-2
Ribbon.Tabs.PDP.Home.Page
-        Ribbon.Tabs.PDP.Home.Page.Previous-Large
-        Ribbon.Tabs.PDP.Home.Page.Next-Large

(click on image for better quality)

Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Clipboard
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Clipboard-LargeMedium-0
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Clipboard-LargeMedium-1
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Clipboard-LargeMedium-1-0
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Clipboard-LargeMedium-1-1
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Clipboard-LargeMedium-1-2
Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Update
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Update.EditPWAProject-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Update.SaveProject-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Update.Close-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Update.PublishProject-Large
Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing-Large-0
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing-Large-0-0
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing-Large-0-1
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing-Large-1
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing-Large-2
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Editing-Large-3
Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Task
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Task.NewTask-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Task.DeleteTask-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Task.DeleteTask-Large (Duplicate ID in Project Server 2013)
Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-0
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-1 (icons)
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-1-0
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-1-1
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-1-2
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-2 (dropdowns)
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-2-0
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-2-1
o   Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Data-Large-2-2
Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Navigate
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Navigate.ZoomIn-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Navigate.ZoomOut-Large
-        Ribbon.ContextualTabs.ProjectDrilldown.Tasks.Navigate.ScrollTask-Large


Comments

Popular posts from this blog

Sharepoint 2013 - Fullscreen mode/hide quick launch

If you want to hide the quick launch on a SharePoint page or web part page in 2013 you could of cause use CSS scripts as in 2010.
But as a new thing in 2013 the user have the possibility to click on full screen mode. so why not load your page in this mode and then the user can choose to exit the mode if he prefers.

Add a content editor webpart to your page and click on Edit HTML from the ribbon.
Add the following code:

<script type="text/javascript">
window.onload = function()
{
  SetFullScreenMode(true);
}
</script>

Install DLL in GAC - Windows 2008/2012 (Using Powershell, No GacUtil.exe)

If you want to install a DLL in the GAC and do not have the GACUtil.exe available. Powershell is properly the easiest way to procede.

Before Powershell you would properly just drag the DLL file into the C:\Windows\Assembly but this option is usually not available anymore.

Powershell - Add DLL to GAC So to install a DLL file in the GAC simply execute the below Powershell script. Remember you migth want to run the Powershell prompt as an administrator.
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")$publish=New-ObjectSystem.EnterpriseServices.Internal.Publish$publish.GacInstall("c:\temp\MyDllFile.dll")iisreset
The first line adds a reference to the assembly we need to be able to mange the GAC.
The second and third lines retrives the GAC object and publish a new DLL file to it.
The last line resets the Internet Information Services. This is only needed if your DLL file is used in a websi…

SharePoint/Project Server - Firewall port open list

Firewall port open list Every time I have to install a new instance of Project Server I forget which ports have to be open.
The ports are divided into 3 lists, one list for the web front end servers, one list for the application server and one list for the SQL server.
These ports are based on a 2013 installation of SharePoint/Project Server. the 2010 installation defer a little bit.


Web Frontend ServerWhen a range is specified all ports between the range must be opened.
     Port(s)ProtocolBoundDescription
-80 TCPInhttp
-443 TCPInhttps/ssl
-25 TCPInSMTP for e-mail integration
-16500-16519TCPInPorts used by the search index component
-22233-22236TCPIn/OutPorts required for the AppFabric Caching Service
-32843-32845TCPInCommunication between Web servers and service applications
-32846TCPIn/OutSharePoint User Code Service
-808-809TCPInOffice Web Apps
-5725TCP