Event Receiver to Remove “Recent” from SP2013 Quick Launch

I’m sure removing the Recent heading from the Quick Launch in SharePoint 2013 has been talked about a million times over since SharePoint 2013 was launched. It’s been solved in this way and that way, by hand, with javascript and programmatically. In this post, I share the code to remove the heading with the ListAdded event receiver.

With and without the Recent heading on the Quick Launch navigation.
With and without the Recent heading on the Quick Launch navigation.

Event receiver code

It’s based on code provided as an answered on the SharePoint StackExchange website by Remko van Laarhoven. I’ve then wrapped in a list added event receiver so that it is executed each time a new list or library is added. As the list/library is then not available on the Quick Launch I’ve added a couple of lines to then show it.

Update (22nd June 2014): since creating this solution I have since discovered that the Recent heading still is created even with the event receiver triggering when lists/libraries created from templates. I resolved this by adding a sleep before the code to remove the heading is executed.
[code language="c"]
System.Threading.Thread.Sleep(1500);
This in conjunction with the jQuery method prevent users from ever seeing the Recent Heading whether they are viewing the page or editing the links on the page.
[code language="js"]
// Hide Recent on Quick Launch
$("#ctl00_PlaceHolderLeftNavBar_QuickLaunchNavigationManager .ms-core-listMenu-root li:contains('Recent')").children().remove();
$("#ctl00_PlaceHolderLeftNavBar_QuickLaunchNavigationManager .ms-core-listMenu-item:contains('Recent')").remove();
[code language="c"]
public class ListAddedEventReceiver : SPListEventReceiver
{
public override void ListAdded(SPListEventProperties properties)
{
base.ListAdded(properties);
SPWeb web = properties.Web;
if (web != null)
{
//Sleep
System.Threading.Thread.Sleep(1500);

//Remove heading
var title = SPUtility.GetLocalizedString("$Resources:core,category_Recent", null, web.Language);
SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
foreach (SPNavigationNode node in nodes)
{
if (node.Title.ToLower().Equals(title.ToLower()))
{
// Delete the recent heading node
node.Delete();
break;
}
}
// Show list on the quick launch
SPList list = web.Lists[properties.ListId];
list.OnQuickLaunch = true;
list.Update();
}
}
}

Download Remove Recent Heading Solution

For those who don’t want to create the event receiver themselves in Visual Studio or don’t know how to, I have a packaged the solution so that you can deploy the WSP to your environment. For those who don’t know how to use this code, I will write a post explaining how to create this event receiver using Visual Studio from an IT Pros perspective very soon.

jcallaghan.removerecentheading.wsp

As with anything you download from the internet remember to review, rename and test this code/solution before using it in a production environment.

Long live the best SharePoint ULS Viewer

Update (15th June 2014): We may see a return of the SharePoint ULS Viewer very soon. Jeremy Thake and Office Dev indicated it is coming back to life very soon.

 

 

Community Discussion (9th June 2014): SharePoint Consultant and MVP Vlad Catrinescu has started a discussion about possible replacements for the ULS Viewer on the SharePoint Community site (http://sharepoint-community.net/forum/topics/what-is-the-best-replacement-for-ulsviewer).

After noticing a tweet from Brian Lalancette ‏(@brianlala, you might also know him through his AutoSPInstaller project), I gasped at the thought that the best ULS Viewer for SharePoint is no longer going to be available.

Along with many others in the SharePoint community, I was quite surprised by this news and started to consider what alternative was available. I’ve used the ULS Viewer from MSDN so many times I have lost count and don’t know where I would be without it.

The best ULS Viewer
The best ULS Viewer

For those who’ve found this post and just want to download a copy of the ULS Viewer tool, you’re in luck. I have preserved a copy of ULS Viewer as a .exe and a .zip archive – these are available here http://bit.ly/UlsViewer and http://bit.ly/UlsViewerzip.
You might receive a warning from the URL shortening service when using the .exe link warning against directly downloading an exe – this is why I have also provided a ZIP version.

Other SharePoint ULS Viewer tools…

As the ULS Viewer is no longer available I thought I shared some alternative tools or techniques to get access to the SharePoint ULS logs.

ULS Studio

A Codeplex project that I’ve used on several occasions and does somewhat come close to the features that the ULS Viewer tool had – ULS Studio (https://uls.codeplex.com).

ULS Studio
ULS Studio

CSOM for SharePoint Online

If you’re using SharePoint Online you could follow Vardhaman Deshpande’s blog post (http://www.vrdmn.com/2014/03/view-tenant-uls-logs-in-sharepoint.html) and access the ULS logs using the Client-Side Object Model (CSOM).

SPO ULS with CSOM - Vardhaman Deshpande
SPO ULS with CSOM – Vardhaman Deshpande

Developer Dashboard

There’s also the ULS tab within the Developer Dashboard, although this is limited to reviewing errors related to those requests where the Developer Dashboard is displayed or used.

The Developer Dashboard can be activated using PowerShell – SharePoint Developer Devendra Velegandla shares the PowerShell and reviews the Developer dashboard on his blog (http://www.sharepoint-journey.com/developer-dashboard-in-sharepoint-2013.html).

$svc = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$dds = $svc.DeveloperDashboardSettings
$dds.DisplayLevel = "On"
$dds.Update()
ULS errors displayed in the Developer Dashboard
ULS errors displayed in the Developer Dashboard

PowerShell

Use can even use PowerShell to get details about a correlation error. Wictor Wilén shares details about this method in an article on his blog (http://www.wictorwilen.se/Post/Working-with-SharePoint-2010-Correlation-ID-in-PowerShell-and-code.aspx).

Get-SPLogEvent | out-gridview
Get-SPLogEvent | Out-GridView
Get-SPLogEvent | Out-GridView

Summary

While I’m not going to stop using the ULS Viewer – I can only recommend you use something to help you view the SharePoint ULS logs. Troubleshooting SharePoint is not easy but you can help yourself, firstly by always checking the event log and secondly being comfortable with your method of doing.

Long live the best ULS Viewer.

Provide feedback directly to Microsoft about Office 365

I have just discovered that you can give feedback about your experiences using Office 365 directly to Microsoft using their online feedback form (http://msft.it/o365feedback) thanks to a Tweet from Jennifer Mason.

The Office 365 Twitter account shortly replied with a useful link to provide feedback.

It is a great tip for those working with Office 365, SharePoint Online and Yammer etc who want to pass on feedback to Microsoft about their experiences using Office 365.

The Deployment Guide of all SharePoint 2013 Deployment Guides

Let me introduce you to the Deployment guide for Microsoft SharePoint 2013. Anyone deploying, installing or configuring SharePoint 2013 absolutely must read this!

This particular Deployment Guide is 674 pages long and like no other. It was published by the Microsoft Office System and Servers Team at Microsoft back in October 2012.

It is such a great guide and is packed full of information. Reading through the deployment guide, I discovered some neat little tricks and refreshed myself on some pretty important best practices which are always a good exercise.

Download it now, get reading and share it!