Unable to change Content Type of document in Library

I was trying to remove a content type from a document library which was associated with multiple content types. As a first action, I identified all documents tagged with the content type to be removed and tried to update them with another content type. However some documents were still showing the old content type despite saving it with the new content type by updating the [Content Type] field.


I tried removing the document and adding the document back to the document library, unfortunately it was still referencing the old content type.

The solution that worked for me was to open the document in desktop office and open the “Advanced Properties”.


Find and select the property ContentTypeId and click on Delete.


After deleting the ContentTypeId property I was able to update the content type property of the document and eventually remove the old content type from the document library.

Search Display Template js file not created when HTML file for Item_ThreeLines is created

On a SharePoint Online site collection where Publishing feature was initially turned on and subsequently turned off, js file was not automatically created/updated whenever a display template was created/edited.

We wanted to have a search content web part with three lines instead of two lines. We created a new display template by following the steps below.

  • Navigate to Site Settings>Master Pages>Display Templates>Content Web Parts.
  • Download the file Item_TwoLines.html
  • Rename it to Item_ThreeLines.html
  • Edit title to Three Lines and wherever reference to Line 2 is made add corresponding reference to Line 3

  • Import the file into the  Site Settings>Master Pages>Display Templates>Content Web Parts library

However the js file was not created automatically since publishing feature was turned off.

The only option was to create the html display template in a site collection with publishing feature turned on, wait until the js is created automatically and migrate the js file and HTML file into the site collection where publishing feature is turned off. If the properties below are not set automatically, manually set the highlighted properties while uploading.


The Item Template is accessible from any search web part added to the non publishing site collection


CSS to update display of items in SharePoint List View with alternating colour

The list view display of items in a SharePoint List can be updated to have alternating row colour and border set by using CSS.


To test the snippet below, edit the page displaying the list items and add a content editor WebPart. Copy and paste the CSS snippet into the content editor WebPart.

<style type=”text/css” unselectable=”on”>
/* ——- Set Alternating Rows ——- */
/* ——- Set background for every row ——- */
.ms-listviewtable > tbody > tr {
background: white;
/* ——- Set border for every row ——- */
.ms-listviewtable > tbody > tr td{
border-bottom: 1px dotted black !important; /* !important needed over override SharePoint inline style */
/* ——- Set background for every alternating row ——- */
.ms-listviewtable > tbody > tr.ms-alternating {
background: lightgrey


After saving the CSS, the list view is transformed into alternating coloured row with dotted border bottom.


SharePoint JavaScript OOB Utilities URL

SharePoint provides Out of Box JavaScript libraries to manipulate URL property.

GetUrlKeyValue(KeyName, bNoDecode, url, bCaseInsensitive)
Gets the key value from url. The second parameter is a Booleans indicating whether the value needs decoding and the last parameter indicates whether key is case sensitive

SetUrlKeyValue(keyName, keyValue, bEncode, url)
Set the value of key in the Url. The third parameter indicates whether the value needs to be encoded

The two functions below are useful before saving a file to detect any illegal characters in url and file name as both have different sets of illegal characters.
http://&#8221;, question mark, hash, ssemicolon and ampersand have to be stripped before passing to these functions otherwise they will be interpreted as illegal characters.

//check URL
//check file name

An example of the use of the functions are below

var currentUrl = _spPageContextInfo.webAbsoluteUrl.replace("http://", "") + _spPageContextInfo.serverRequestPath;

var illChar = IndexOfIllegalCharInUrlPath(currentUrl);


Allows to replace all instances of one of six SP specific tokens in a URL
{ItemId} {ItemUrl} {SiteUrl} {ListId} {Source} {ListUrlDir}

The code below uses the function to obtain listId , SiteUrl and ListUrlDir which is the rootfolder Url of the list.

var tokenizedUrl = "http://www.test?list={ListId}&SiteUrl={SiteUrl}&ListDir={ListUrlDir}"
var url = ReplaceUrlTokens(tokenizedUrl,ctx);
var listId = GetUrlKeyValue ( "List",false, url, true);
console.log("ListId:" + listId)
var siteUrl = GetUrlKeyValue ( "SiteUrl",false, url, true);
console.log("siteUrl" + siteUrl)
var ListUrlDir = GetUrlKeyValue ( "ListUrlDir",false, url, true);
console.log("ListUrlDir:" + ListUrlDir)

SP.Utilities.UrlBuilder.urlCombine(string1, string2)
Combines the two string parameters without redundant slashes between them. However only works if second string does not begin with a slash.

Removes key value parameter from url.

var urllink = "http://test.com?param1=200&param2=900"

Get relative URL for specific layout page for current context
It is useful when writing in a mixed 2010, 2013 mode where some sites have been upgraded


It takes the browser to specified url. It is useful when the page url is loaded into a SP modal dialog then the new page that gets loaded will remain inside that dialog as well.

Copy the code into a script editor web part to test.

<a onclick="SP.Utilities.UrlBuilder.navigateTo('http://www.google.com')">Navigate in Dialog</a>
<a href='http://www.google.com')">Navigate without Dialog</a>

var testUrl = SP.Utilities.Utility.getLayoutsPageUrl(“test.aspx”)
var urlBuilder = SP.Utilities.UrlBuilder(testUrl);
console.log( urlBuilder.get_url());

KQL SharePoint Online filtering on user profile multi values managed metadata properties

Keyword Query Language (KQL) is a powerful way to query search results in SharePoint Online.

It is possible to filter data based on the user profile property ,e.g. owstaxidJobTitle:{User.SPS-JobTitle}

The above is a valid property restriction which will return all items having the managed metadata field JobTitle equal to the user profile property JobTitle of the logged in user.

When managed metadata field is crawled, two crawled properties are created in the format of ows_taxid_ and ows_. The ows_taxid_ is mapped to managed property owstaxid. The managed property owstaxidJobTitle stores the crawled property of the managed metadata field JobTitle.

Let’s say if user profile managed metadata property is multi valued. All items matching all the values in the user profile managed metadata property need to be returned.

The KQL achieves the goal of returning all items with managed metadata field ItemTopic contain any terms tagged against the “Ask Me About” field of the logged in user assuming the “Ask Me About” has been mapped to a term set.


SPS-Responsibility is the internal name of “Ask Me About” field from user profile.

The above snippets can be tested using the Content Search Web Part.

Challenges using SSRS SharePoint Integrated Mode in Chrome when kerberos is enabled

On one client’s environment SSRS reports on Dev, Test and Live SharePoint 2013 Integrated mode with kerberos used for authentication will not load if they are opened in Chrome. Only the loading wheel can be seen. If the browser’s developer tool is opened, the same requests in being sent non stopping. This is happening when the SSRS report is opened either from report library or through a SSRS web part on a page.

I tried several solutions as follows from either suggestions from colleagues or from blogs to no avail

– Update Chrome from 3.x.x to latest 37.0.2062.120

– Update Microsoft SQL Server 2012 RS Add-in for SharePoint to SP1 CU9

– Test using different test users with different levels of permissions while still logged in to the machine as the same user

– Checked whether SSRS integrated mode for SharePoint 2013 has properly been configured

– Disabled Antivirus  and Firewall on the machine

– Checked ULS logs, developer tools for any error while rendering the reports without any luck.

Finally decided to create a new web application using NTML instead of kerberos for authentication with a site collection. The SSRS reports render well from the new site collection.

It seems the authentication token was not passed correctly to the SQL reporting services when Kerberos is turned on. Though not an ideal solution, the only option I found with the help of a colleague was to change the Internet Options to “Prompt for user name and password” whenever the user opens the browser.

GetFieldValueAsHTML on multiline textboxes return instead of

The <br/> gets inserted whenever shift>enter is pressed  inside a multiline text box in SharePoint list.


Above is a sample text entered in multiline column Col_ToBeDel.


When the getfieldvalueashtml method is called against the column value , <br> is returned instead of <br/> tag.

If LoadXML method is called against the value returned by getfieldvalueashtml , it will complain about invalid XML. The fix can be to replace <br> with <br/> before calling LoadXML.