Show versioning in a custom page

Customizing a SharePoint site (customizing means develop from scratch some pages with SharePoint Designer, of course based on a custom master page, and show and submit data from these pages), I was required to show version history for items in a custom list. Without server side, I had not fast way to do this. However, even if is not a nice solution, you can always read and parse “Versions.aspx” built-in application page. Let’s assume you already know list item and list id.

var listId = '{52CD7375-1125-4166-9741-DF8BFC0A2648}';
var listItemId = '140';

Create an empty table tag in your custom page and assign and ID.

<table id="versions"></table>

With some help from jQuery, is now the time to make an Ajax request to Versions.aspx, parse the response and populate our table with data.

    url: 'siteurl/_layouts/15/Versions.aspx?list=' + listId + '&Id=' + listItemId,
    cache: false,
    data: 'html',
    success: function (data) {
        var html = jQuery(data).find('.ms-settingsframe').html();

This code is doing the job. But there is only one thing left. You might be require to remove as much as possible direct access to the back-end, so a normal step is to remove “href” attributes for links and “onclick” events. In this case, you need to re-rewrite a little bit the Ajax request:

    url: 'siteurl/_layouts/15/Versions.aspx?list=' + listId + '&Id=' + listItemId,
    cache: false,
    data: 'html',
    success: function (data) {
        var html = jQuery(data).find('.ms-settingsframe').html();
        var noHref = /(href="([^>]+)")/ig;
        var noClicks = /(onclick="([^>]+)")/ig;
        html = html.replace(noHref, '').replace(noClicks, '');

As I told you, this is far away from being an elegant solution. But in some case it might be sufficient and you can start continue working on other tasks.


Customize Word template for document library

The power of SharePoint is integration with other Office application, like Microsoft Word. Very easy, a normal user can create a document library based on Microsoft Word template. When user clicks on “New Document” button, a Microsoft Word document is created. Behind the document there is a template, called by default “template.dotx” and placed inside document library folder, in a sub-folder called “Forms”.

But probably any company with SharePoint installed as intranet will want to have some documents with special formats. And this is the point when a user might decide to have his own template instead of default one. For this is sufficient to follow the next steps:

  1. Open Microsoft Word application, create a document template (with extension dotx), customize it and save it on your computer. As an example we choose “MyTemplate.dotx” as file name.
  2. With SharePoint Designer open the website, navigate to document library’s “Forms” sub-folder and upload document template you have just created.
  3. Go to library settings and navigate to “Advanced settings” menu. In the Template URL textbox, change URL accordingly. In my case I change it to “Word Documents/Forms/MyTemplate.dotx” as “Word Documents” is the name of document library and also the URL of the root folder and “MyTemplate.dotx” is the name of template file. This straight forward and there is not much to explain here.

Any user who completes these steps has a “Bingo!”. Now, a document with predefined layouts is created by clicking on “New Document” button.

Integrate Word document template with fields

When you create custom fields in the document library, these fields become document properties. For example we might want to create “Last Name” and “First Name” fields and we intend to use them in the documents. Just go to “Advanced settings” and click “Edit Template” link.
In this moment, Word client application will open the template we have uploaded in order to edit it.

Our work is an easy one from this point. In Word 2013, document properties can be inserted extremely easy from Quick Parts -> Document Property menu.
From now, changes done to Last Name and First Name fields are reflected into the document content.

Remove hyperlink from lookup field in XSLT list view web part

When you read the title you probably think I will discuss about client side rendering, but I am not. This example is based on SharePoint 2010 an no client side rendering is available for this web part. But you still can do this using classic XSLT and customize only specific items from the view.

I had a list containing time off requests with a lookup column called “Activity” (internal name is the same). By default, this kind of field is render like a hyperlink to the item from lookup list and, by mistake, some users clicked on this link instead of clicking on edit icon.

Timesheet - 0_Start view - Internet Explorer

If you want to remove the hyperlink, open the page with SharePoint Designer and add this code below “XmlDefinition” node.

<xsl:stylesheet xmlns:x="" xmlns:d="" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="" xmlns:asp="" xmlns:__designer="" xmlns:xsl="" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
<xsl:include href="/_layouts/xsl/main.xsl"/> 
<xsl:include href="/_layouts/xsl/internal.xsl"/>


And now we are ready to add customization code for “Activity” field, which contains only a few lines of code, inside “xsl:stylesheet” declaration.

<xsl:template match ="FieldRef[@Name='Activity']"  mode="Lookup_body">
<xsl:param name="thisNode" select="." />
<xsl:param name="activity" select="substring-after($thisNode/@Activity.,'#')" />
<xsl:value-of select="$activity" disable-output-escaping="yes" />

Please note that activity parameter doesn’t take the value from “@Activity” attribute of current node. Instead “@Activity.” is used (a dot is added to attribute name). Also, we need to make a “substring-after” operation because the data obtained from the server has this format: “2;#Holiday”.
Timesheet - 1_My time - Internet Explorer

Microsoft Access slow performance working with SharePoint lists

Using Microsoft Access with linked tables to SharePoint lists is a common scenario even in large companies because is the easiest way to change bulk data stored on SharePoint sites. So being asked to perform some update operations on SharePoint lists, I have discovered I could do nothing, because Access was simple freezing trying to run the queries. Was a surprise for me because I had no problem when I have used Access installed on Windows 7. All of the problems appeared once I have installed and update Windows 8.1

I did a Google search for similar issues. I tried different proposes solutions until I have reached this article.

It turned out security update KB2992611 created some performance issues for ODBC connections and I did not see this before because I did not install all Windows updates. Immediately after I removed this update, Access performance was back to normal.

I hope this will help you to solve similar situations you might see. Before going to other solutions, remove the update and see if the issue is fixed.