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

Error occurred in deployment step 'Add Solution': Attempted to perform an unauthorized operation.

Received this error today when trying to create a SharePoint solution against a newly created site.


My first problem was the site was configured to use a port which was already used by another web site. Therefore the site could not start at all.

In my case both Default Web Site and SharePoint - 2000 was both using port 2000. Changing the port of Default Web Site and I was able to start the site.

However now I still received the same error message. When browsing the site I realized I did not have access to the site.

Giving access to my user and I was able to deploy the solution.

To sum up this post:
 - Check the site can start
 - Check the site can be browsed
 - Check your user have access to the site

SharePoint 2013 : Cannot connect to the targeted site.

On my Contoso environment I was trying to create a sandboxed solution. I have already configured my app domain and app management services. But when I tried to validate the site I got the following error message.
Error

Cannot connect to the targeted site. This error can occur if the specified site is not hosted on the local system. SharePoint solutions work only with locally-installed versions of SharePoint Foundation or SharePoint Server. Remote development is supported only for apps for SharePoint 2013.
If you search around the internet you will find many people suggesting to change your host file from 127.0.0.1 to the actual IP.

Solution However the solution, at least on a Contoso environment, is to type in the actual IP address in the host file.
(the IP 192.168.150.1 is the special IP for Contoso, I have 2 network adapters)
And do not forget to clear/flush the DNS cache. Now the solution can be created and validates.


PowerShell results size unlimited/truncated - $FormatEnumerationLimit/Width

Ever experienced the problem where you run a Powershell command and you cannot see the whole result because the result is truncated.

Problem: If you for example run the Test-SPsite command you might see something like the following:


Site : SPSite Url=http://atlas/pwa Results : { SPSiteHealthResult Status=Passed RuleName="Conflicting Content Types" RuleId=befe203b-a8c0-48c2-b5f0-27c10f9e1622, SPSiteHealthResult Status=FailedWarning RuleName="Customized Files" RuleId=cd839b0d-9707-4950-8fac-f306cb920f6c, SPSiteHealthResult Status=Passed RuleName="Missing Galleries" RuleId=ee967197-ccbe-4c00-88e4-e6fab81145e1, SPSiteHealthResult Status=Passed RuleName="Missing Parent Content Types" RuleId=a9a6769f-7289-4b9f-ae7f-5db4b997d284, SPSiteHealthResult Status=FailedError RuleName="Missing Site Templates" RuleId=5258ccf5-e7d6-4df7-b8ae-12fcc0513ebd, …