Category Archives: SharePoint

Convert Script-Editor-Webpart-Textarea to a real code editor with CodeMirror.js

I use the Script Editor Webpart very often and what always bothers me is that there is no proper code formatting in the textarea. So after some messing around with the CodeMirror-editor (a text editor implemented in JavaScript), I came up with a piece of code which will convert the textarea of a Script Editor Webpart to a real code editor including syntax-highlighting, proper indenting, fullscreen-editing, search, etc..

Continue reading

QuickTip: Find out whether the page is in edit mode or not

You just want to run a script if the page is in edit mode or just execute if it is not?
Use this little function (requires jQuery) to check whether the page is in edit mode or not:

function checkIfEditMode(){
	return ($("#MSOLayout_InDesignMode").val() || $("#_wikiPageMode").val()) ? true : false

This script will work Web Part pages, SharePoint Publishing pages and Wiki pages.

QuickTip: SharePoint Attachment Field in List Forms

To show the attachment field in the form as in the above screenshot without the need to click the ‘Add attachment’-button in the ribbon, simply edit the form and put the script below into a Script Editor Webpart. This Script requires jQuery.

	//Get all the ribbon buttons from the action-group
	var $ribbonAttachButton = $("#Ribbon\\.ListForm\\.Edit\\.Actions a")
	//If the 'Add Attachment'-button is the only button in the group then hide the group, otherwise just hide the button 
	$ribbonAttachButton.length == 1 && $ribbonAttachButton.closest("li").hide() || $ribbonAttachButton.hide()
	//Get the iportant elements of the hidden attachment field
	var $attachElements = $("#csrAttachmentUploadDiv > #partAttachment > table > tbody > tr:eq(1),#csrAttachmentUploadDiv > #partAttachment > table > tbody > tr:eq(4)")
	//Get the 'OK'- & 'Cancel'-button
	var $attachButtons  = $attachElements.find(".ms-attachUploadButtons")
	//Insert an empty cell in order to adjust to the form's layout
	//Align buttons to the left
	//Remove some margin and rename the 'OK'-button
	//Adjust the fields label to match the rest of the form, adjust the height
	$attachElements.find(".ms-formlabel").html("<h3 class='ms-standardheader'>Add Attachments</h3>").css({"height":"auto","width":"auto"})
	//Make the file-selector bigger
	//Move elements to the end of the form table
	$attachElements.appendTo($("#part1 > .ms-formtable"))

Starting Workflows (SP 2010 WF Engine) With 1 Click

It always annoyed me that if you want to start a SP2010 workflow manually from the items context menu or the ribbon you are redirected to the page where you have to click yet another button to finally start a workflow.

But there is an better way. With a small script and with the help of the SPServices JavaScript library you can start workflows with just one click.

Continue reading

Change the Access Denied message

If you don’t have sufficient permissions to access a SharePoint resource you are presented with one of three messages. If you have Access requests activated for the site you will see something like this:

From my experience many people tend to think that this is just a plain error message and click it away, followed by an email with the question to please provide the necessary permissions to access the resource. They don’t *really* realize (or know) that they can send a request with a custom message which the admin will read and cause him to react accordingly. That means that the big advantage of sending a request in the context of a resource stays untapped and the email odyssey begins in which you (the admin) try to figure out what the user has just clicked right before this message appeared.

Continue reading

SharePoint Server 2013 SP1 released

Microsoft has just released the first Service Packs (SP1) for their new 2013 Office and SharePoint Products. The new Service Packs contain new fixes as well as the Cumulative and Public Updates from December and January, respectively.

The fixes that are included in the Service Pack for SharePoint Sever 2013 are as follows:

Continue reading

(Updated) Sticky Headers for SharePoint 2013 – v2.0

Update 4th of March, 2016: This script has its own Product Page now and all future updates will be posted there. Should you have any questions, problems or bug reports please use the comment section on the Product Page or the Forum.

A limitation of the StickyHeaders script in version 1.0 is that it is not working in Quick Edit mode. Therefore I updated the script and released version 2.0 which is now also working in Quick Edit mode. You can download the script at the end of this post.

Version 2.0 also eliminates a few bugs that showed up from time to time. While the sticky headers are fully functional in list views, the sticky headers lose their functionalities in Quick Edit mode, but I hope that I can address this issue later (I already got an idea how to do it, so check back a bit later if you need these functions).

Continue reading

(Updated) Open list item attachments by clicking the paperclip – Version 2

Update 28th of July, 2014: Script updated to version 2.3 (see the changelog)

End of January I adapted the script to open list item attachments with a simple click on the paperclip symbol, which Alexander Bautz from wrote, to SharePoint 2013.

In the last couple of days I have made some further improvements to this script which I want to share with you.

Continue reading

Open list item attachments with a click on the paperclip

UPDATE February 13th, 2014: An even newer version is now available which you can check out here.

Another requirement of one of my users is to open file attachments directly by clicking on the paperclip icon without the detour of opening the item first. Alexander Bautz from wrote the perfect script for this purpose which you can find here on his blog post. Thanks for that!

However, the last update was from mid 2012 and therefore the latest version is not compatible with SharePoint 2013. I made some minor adjustments to the code to restore the compatibility and I added a fade-in and fade-out animation, as well.

Continue reading

Fix the AppFabric Caching Service after renaming the Server

Today I made a mistake and renamed a server without removing it from the AppFabric cache cluster. This caused some trouble getting the cache service back to a running and healthy state as well as some ugly error messages in the ULS, such as:

Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage 'DistributedLogonTokenCache' - Exception 'Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode:SubStatus:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.). Additional Information : The client was trying to communicate with the server : net.tcp://old_server_name:22233    
  at Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, RequestBody reqBody)    
  at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCacheProperties(RequestBody request, IClientChannel channel)    
  at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName)    
  at Microsoft.SharePoint.DistributedCaching.SPDistributedCachePointerWrapper.InitializeDataCacheFactory()'.

Continue reading