Category Archives: Chris Grist

SharePoint 2013: Clicking the icon in Type column is highlighting the item instead of launching the document

You may also be interested in: ViewPoint for SharePoint


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

If we step back to SharePoint 2007 before Bieber fever, before the first black US president, before 1D and before many hours lost to Angry Birds; we had a field in SharePoint called DocIcon and when you clicked on it, it would open the associated document.

In SharePoint 2010 the field still existed, but was not wrapped in the <a> tag it so needed to function, Microsoft’s response to beta testers was that it was by design and would not be fixed, and even though it still displayed in the view editor as Document Icon (linked to document), it of course was not linked.

In SharePoint 2010, Microsoft, released a kb on a workaround using a .xsl document dropped in the 14 hive see here, and for those a bit less technical several people packaged this up into a deployable WSP to make the process no harder than any other SharePoint change.

Unfortunately in SharePoint 2013, this seems not to work and several people are looking for an answer. It could be as simple as modifying the XSL, but I know 9/10 people do not like looking at XSL2013-04-02-ClickIcon-01.gif.

Therefore, I have put together the below jQuery which you can drop into your master page, to make the icons clickable. The only scenario I could not get it to work was where a view was grouped and collapsed. However, grouped and expanded did work.

You’re not going to want to implement this if you have massive amounts of items shown at once, but it may help some of you until (if) Microsoft releases another workaround. Of course if this is just for one document library, you can chuck it in a content editor or html web part to apply to the single page.

Add “follow” to SharePoint 2010

You may also be interested in: SharePoint Solutions In-A-Box from Alcero


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

For those of you who have checked out the Office 365 or SharePoint 2013 preview, you would have noticed that Microsoft has added a follow button, on sites and documents, the functionality when clicked basically bookmarks the site similar to a favourite in your web browser.

I have been working on a SharePoint 2010 project for our company, in the new web application there will be 100s of site collections and inside each 100s of sites. The sites are organised logically in a hierarchy, the challenge was that some users will always work in level 4 of the hierarchy and some will work at level 1 or somewhere in-between. As this requirement is not really prescriptive and we cannot know which user wants to navigate where, I needed to develop follow functionality similar to what Microsoft is shipping in SharePoint 2013.

This article looks at the setup and the code that has made this possible and a very popular feature with the end users thus far.

The first step is to decide upon where to store the information, for this I decided to use the user’s profile, so if you’re running SP Foundation, stop here and think about where/how you may store the information instead.

To do this I simply added a new user property called “bimsFollow”. This property was simply a string (multi value) type.


I also made the property hidden from the end user.


The next step was to build a control to be able to follow or un-follow a particular site. For this functionality I decided upon using a user control, this makes it very simply to embed the functionality in an area of my custom master page. So the first step was to open a Visual Studio project and add a new user control, for this I called it “follow”.

The only thing I needed my user control to show was a hyperlink as to whether the user was following the current site or not, so at the bottom of the .ascx file, I added the following code:

The URL and Text will be dynamic based on whether the user is following the site or not, so here I have left it blank and run the control at the server so I have access to it in the code behind.

The next step was to open the code behind file (.ascx.cs). Inside the page_load function I started by adding a couple of Boolean values:

Before constructing the bulk of the functionality I wanted to test that everything was working, so I then added the code to set the hyperlink with the correct URL and text.

I then registered the user control to the master page to make sure what I had setup was working so far, even though the if statement is always going to execute the else block at this stage. Sure enough it appeared to be working, with a bit of CSS styling I ended up with a user control that matched the style of my custom master page:


As you can see from the code above I decided to use query strings to toggle whether the user was following the site or not, so the first thing we had to do before the if statement is called is to get the value for the query string.

If the value exists, then we set the followMe bool to be either true or false based on the input the user has provided on the hyperlink. The next block of code, simply provides the setup for the User Profile Service so that we are able to access the current users profile.

Once we have the profile object we are then able to retrieve the collection of value’s that are currently stored in the user property we created earlier.

The property is actually returned as collection, rather than a delimited set of strings, so we can quite easily iterate over the collection, and then compare whether the stored data (i.e. set of URLs) match the URL of the current site, and therefore indicate the user is following the current site.

We now have most of the functionality we need, the missing piece is simply to add or remove objects from the collectionofPropertys that we have retrieved above based on our previous bool. The first check we therefore do is to whether the followMe bool is true.

If the value is true, then we toggle isFollowing to true, so our hyperlink is configured correctly, and then simply add the URL to our collection of strings in the user profile, finally committing any changes. The inverse is almost as simply, however to remove values you must know the index of that particular value in the collection, so we must first iterate over the collection, find the location of the matching URL and then remove it and commit as show below.

If all has gone successful you will have a fully functional hyperlink that toggles values when you select it:


If you then head over to the USPA and look at the user profile via central admin, you will see the URLs populated:


Now that this functionality is working, you simply need to display a listing of sites a user is following, all the code required is above, in my environment I created a web part, setup the connection to the USPA, grabbed the collection of property’s similar to this article and iterated over the values, opening the URLs and display the title of the site, the end result looked something like this:


The entire block of code for the functionality is below:

SharePoint 2013: New List Promoted Links

You may also be interested in: Secure SharePoint with User Claims White Paper from Titus


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

Today I was looking through the list of out of the box “Apps” in SharePoint 2013 and came across the Promoted Links App.


The description of the App is “Use this list to display a set of link actions in a tile based visual layout”.

It was soon obvious that this list allows you to create your own interface much like “Get Started with your site” that is shown on all new team sites:


To set this up, just follow the following quick guide:

  • Click on the settings menu 2012-08-06-NewListPromotedLinks-03.png and select “Add an app”.
  • Locate the Promoted Links App, click on the icon and then give the app a name.
  •  2012-08-06-NewListPromotedLinks-04.png

  • Once the app has been installed, navigate to it either by the icon, or the quick launch. You will land in the app with the view set to “Tiles”. The app will let you know that you need to switch over to another view to be able to add content to the app.
  • 2012-08-06-NewListPromotedLinks-05.png

  • When in the All Promoted Links view simply add some new items linked to images and SharePoint will take care of the rest.

When you switch back to tiles view you will see your newly created tile:


If you have selected the optionDialog from launch behaviour:


You will end up with a great modal pop-up of what you link to:


You can even load external websites inside these dialogues so your user is not taken away from the site:


And of course you can add the list as a web part on another page:


Finally, when you hover over once of the tiles the tile changes to show you the description of the link item.



SharePoint - InfoPath 2010: Form Library Modal Popup

You may also be interested in: SharePoint-based solutions by B&R Business Solutions


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

In the last couple of weeks I have worked on several InfoPath projects which are using form library’s to save the completed form. However I did not like the way the user was navigated away from the site to enter a new form, several of these forms I wanted to be rapidly completed and therefore I started to look at a different way to open the forms.

Of course in SharePoint 2010 we have the modal popup dialog, and after looking at a list form that had been customised with InfoPath, it appeared that it was possible to have an InfoPath form load inside a modal popup.

The rest of this post details how you would achieve this.

The first step is to get your form ready and published, once this is complete head over to your form library and click add a new item.

Once the form has loaded copy the URL:


You will end up with something that looks like:

<a href=""></a>

If you were to create a normal hyperlink to the above address, the chances are it will try and open in InfoPath client, so therefore we need to remind it to open in the browser using the syntax OpenIn=Browser. Therefore the link we now have saved looks like the following:

<a href=""></a>

To open a form inside a modal popup, SharePoint 2010 uses JavaScript which is linked to in the following format:

<a onclick="javascript:NewItem2(event, "INSERLINKHERE");javascript:return false;" target="_self">Open Form</a>

Insert your link in between the quotes where it says INSERTLINKHERE. Then insert the hyperlink on to a page, I had trouble inserting directly on to a page but inside the a content editor web part works just fine.


Now when we click the link you should receive a modal pop-up and not be redirected to a separate page.


If you don’t need the ribbon controls it can look even slicker:


Geo location Field in SharePoint 2013

You may also be interested in: Smartdesk Advanced ECM Apps


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

Last year I wrote a series of articles on a mash up between a SharePoint list and Bing Maps, it was a three part article and took quite a lot of time to get the end result.

Thankfully in SharePoint 2013 Preview, Microsoft has added the functionality in to achieve this fairly easily. This is achieved with a Geo location field. This field stores location information i.e. Longitude/Latitude which can then be rendered on a Bing/Nokia Map. The one downside is that you’re going to need to crack out Visual Studio 2012 in order to add this field, or at least this is what the examples say on MSDN. Hopefully this is added in to the interface by release, I couldn’t find it anywhere however.

Before you get started sort out the following pre-reqs:

  1. SharePoint 2013 Preview Farm
  2. Visual Studio 2012
  3. Bing Maps API Key Available Here

The first stop is to register the Bing Maps Key against SharePoint; you can achieve this using PowerShell with the following command:

Set-SPBingMapsKey –BingKey ““

You can also do this via code see how here. This will make it easy if you’re packaging up an application that takes advantage of these features.

The next thing to do is to add a new custom list, in this example I have created one called “Office Locations”. In this example I have renamed “Title” to “Name” and added an “About” column of type multi-lines of text.

When you’re done the list should look similar to the following:


Open up Visual Studio 2012 and create a new Console Application, in this example I have just given it a name of AddGeoField.


The first thing we need to do is add assembly references to the two following dll’s:

  • Microsoft.SharePoint.Client.dll 
  • Microsoft.SharePoint.Client.Runtime.dll 


Open the class (.cs) file and add a using statement at the top of the file:

Now we need to add the code to the console application I have made this generic to read in the arguments, this way we can reuse the same console application anywhere in our farm.

Build the solution and then run the application from the command line, replace the arguments with ones relevant to your environment. Make sure the account your running under has sufficient permissions to access the site collection/web/list.

AddGeoField.exe http://sp2013 “Office Locations”

Now if we go back to our list, we can see the Location column has been added of type Geolocation.


When adding a new item, we can either use the current location which will be useful for devices with GPS built in, or add the longitude/latitude of the current location.


When you click specify location, a second modal popup opens where you can specify the values required:


Once valid values have been entered, a Bing map preview is displayed to give you a indication that you have the co-ordinates correct.


After adding a few office locations, the list will look similar to the following:


You can view the Bing Map in various ways:

  1. Opening a list item:
  2. 2012-07-23-GeoLocation-09.png

  3. Clicking on the 2012-07-23-GeoLocation-13.pngicon in the geo location field, this is a great way for a fast preview:
  4. 2012-07-23-GeoLocation-10.png

Lastly, you can also now create a map view, if you create a new view, you will see a Map View type.


When I was creating my view I got an error, but the view created anyway, when you switch to it you get a awesome representation of all the list items.


I think you would agree this is a lot easier than what we had to do in previous versions of SharePoint. I would love to see uses you can come up with when you put this in to practice.

If you want to save some time I have uploaded my compiled solution for you to use: Add Geo Location (5)

InfoPath 2010: Display Version Number on a Form

You may also be interested in: O’Reilly - SharePoint 2010 at Work


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

Each time you save a form template with InfoPath, there is a version number that is incremented, shown below:


I find it useful to know which versions are being used, especially if I have to troubleshoot a reported issue.

Thankfully it’s quite easy to display this version number on the form its self. To achieve this just add a calculated field to the form:


Then paste in the following to the XPath text field:


Now when you preview the form you will see the version number:


SharePoint - InfoPath 2010: Splash of Metro

You may also be interested in: SharePoint-based solutions by B&R Business Solutions


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

A few weeks ago Windows 8 Release Preview shipped. I have been looking at Windows 8 from a far to date, but I attended one of the free developer camps hosted by Microsoft which helped understand how to actually use Windows 8. After the event I loaded up my laptop with the OS and am slowly getting used to it. I decided to do some InfoPath design based on metro principals and make it similar to Windows 8.

Looking at the form on Windows 8 does make it look a bit nicer, but I tried it out on a Server 08 box and it wasn’t too bad.

Here’s a screenshot of what the form looks like.


I’m using the recommended font sizes from Microsoft for the typography (42->24->11->9), and Sergoe UI for the type face. One bit of trouble I ran in to is that for some controls InfoPath doesn’t let you have a border, therefore I had to use a wrapper table with a border set and remove all the margins and padding.

Once I had created the top section of the form, I started out on the app bar at the bottom. Keeping in with the Windows 8 design principal, the contextual icons are on the right and the global icons are on the left. Here are a couple of examples from different views.

View 2 (presumably the last view of the form and therefore has the save/submit button).


Help View (It may be worthwhile having a help view for each form page, this way the back button would go back to the correct view, currently its going back to the start of the form).


Here is the help view in full. Just with some filler text for now.


To give you a jump start I have uploaded my xsn to download. As for the icons for the app bar, I found a useful set located here:

I expect when the Beta of Office 15 hits hopefully containing InfoPath 15, it may be easier to crea<p>te metro inspired forms.

Metro Form (3)

SharePoint: InfoPath 2010 - Create Reusable Content

You may also be interested in: Social Sites 2010 by NewsGator


Editor’s note: Contributor Chris Grist is a SharePoint Architect at Beach Energy. Follow him @gristdog

If you’re reading this you most probably create InfoPath forms, this can quickly turn in to creating a lot of InfoPath forms. In any type of development it’s a great idea to create re-usable content and InfoPath is no different. Therefore today I am going to take you through InfoPath Template Parts. I saw a great presentation on this at #AUSPC by Patrick Halstead and I am now starting to build up some template parts of my own.

So as it sounds template parts, are part of a template, let’s first create one by cracking open InfoPath 2010. Then select a blank template part from the new menu:


For this example I am going to make an address table, an address may be something you want to capture in multiple forms. Simply drag and drop the controls you need to the main pane.

The end result looks like this (I used one of the inbuilt table styles):


As I am sure you do already, give the fields some useful names. The names I have used are shown below:


We now have our template part ready to go. Click on File and then save as, give the template part a name and save somewhere on your disk (or even to SharePoint). You will notice the format is XTP2 and not XSN indicating that it’s a XML Template Part.

Next on the Controls section of the ribbon, click the expand all the controls and then click Add or Remove Custom Controls.


A new window will open, click on Add, follow the wizard selecting template part and browse to the location you saved the XTP2 and select it. Your custom control has now been successfully added to your palette of available controls.


Close and re-open InfoPath, this time select Blank Form. From the controls menu select the Address template part you created, and watch it instantly appear in front of you, and if you have a look over to the fields section, you will notice why it was so important to give some proper names with your fields.


Now you’re done. I hope this makes you more productive and not need to recreate those common form controls over and over again. Use template parts as reusable content to rapidly develop forms and be consistent in the design at the same time.

SharePoint Feature Stapling: Staple the Feature

You may also be interested in: SharePoint Video Training at TRAINSIGNAL


Editor’s note: Contributor Chris Grist is a Senior Technical Consultant for Loftus IT. Follow him @gristdog

In the last article we went through and created ourselves a site collection scoped hidden utility feature that changed some properties in the root web’s property bag and also switched the locale to English (Australia).

This time I am going to show you just how easy it is to staple this feature, so that the feature will get activated when a new site collection is created, thus having consistency between all site collections that are created.

Step 1: Add the new Feature

The first thing you will want to do is open up the project we created last time. Once you have done this we will need to add a new feature the same way as last time selecting the features folder and selecting Add Feature.


Configure the feature up with useful information, similar to what I have done below. For now I am testing against a single web application, you may want to scope this to farm later to work across every web application in the farm.


Step 2: Add an Empty Element

Right click the solution and then add a New Item of type Empty Element.


This will jump you in to an Elements.xml file which we will update in the next step. First flick back over to your stapler.feature and make sure the Element is deployed with your WebApp feature and not your Site Collection one. I had to switch this around. To do this simply use the arrows in the centre column.


Step 3: Configure the Stapler

The last step is to configure the stapler, this is done purely in the Elements.xml file that opened just before for our empty element. Inside the elements tag, add the following line of XML.


The ID is the one we saved in the previous article, this is the ID of the feature that we want to associate or staple. The TemplateName is the code for the template we want, you can specify specific codes such as STS#0 etc., Or simply put GLOBAL to staple it to everything. For our utility feature it makes sense to staple this globally.

Now you are ready to deploy the feature, so go ahead.

Step 4: Check the web application feature is deployed and activated

Before creating any new site collections for testing it’s a good idea to inspect the web application to ensure the feature is deployed. Simply navigate to the list of web applications, select the one you are after and then click on Manage features. You should see something similar to this:


Step 5: Create a new Site Collection

You are now ready to create a new site collection, so go through and create one of any template that you wish. Inspect the locale and search settings and you should find them all ready to go and configured.


To recap in Part 1 we created a utility feature to configure locale and search settings, we then stapled this to all site templates using a feature stapler. Once this was completed we created a site collection and made sure it all worked.

SharePoint Feature Stapling: Create the Feature

You may also be interested in: Build a Scalable Architecture by KnowledgeLake


Editor’s note: Contributor Chris Grist is a Senior Technical Consultant for Loftus IT. Follow him @gristdog

In this two part series, you will learn how simple feature stapling can be. The first article will actually build a useful site collection feature that if your outside the US you will find very handy.

So what is feature stapling?

Quite simply feature stapling allows you to instruct SharePoint to activate features (that have been stapled), when a web is created. This can ensure certain features are always activated for particular site templates or for anything. This can be a useful way to hide utility features like the one we are going to build today away from users who have the rights to activate/deactivate features. I also use it quite commonly to apply branding to site collections created by non-SharePoint administrators such as My Sites.

Let’s make a feature

The first thing we are going to do is make a feature to actually staple, this way we can see the process from end to end and get a useful feature at the end of it as well.

The feature that we are going to build is a nice utility feature that is going to accomplish the following:

  1. Set the Locale of the site collection to Australia.
  2. Set the Search Centre to be /Search/Pages
  3. Set the Scopes Dropdown to be “Show scopes dropdown”

Pretty simple stuff, but getting this automatic and consistent will help with governance in the SharePoint farm and also save SharePoint Admins some time. I normally also set branding to be activated and any other farm specific features, but the above should be applicable for most people.

Step 1: Create the Solution

First thing you are going to do is fire up Visual Studio 2010 and create a New Project. Create a SharePoint Empty Project with a meaningful name.


I am going to deploy this as a farm solution to one of my test sites. Once you have completed the wizard, you will end up with something like this:


Step 2: Add the Feature

As we are not going to be adding any components to this solution, we need to first add the feature manually. Right click on the features folder, and select Add Feature.


This will open the new feature Feature1.feature up in the new window. Configure a decent name and description, and set the scope to Site which is the site collection level.


Whilst still on this screen at the bottom of the pane click on “Manifest”, this will generate a preview of the packaged manifest, scroll across until you find “Id=”. This is the Feature ID and we will use this in Part 2, so keep it safe for now and it will save time later.


I would also recommend you select the feature in the solution explorer and rename it to something meaningful. I often suffix the scope of the feature to make it simple to see which scope the feature is going to be installed at.


Now expand the plus symbol next to the feature, until you reveal the feature template xml. Double click this file and it will open in the left pane, to make this feature hidden you will need to configure the Hidden parameter as shown below, this is case sensitive so I recommend using intelisense when modifying the template file.


Step 3: Add the Feature Receiver

In the previous step we did all the ground work to configure our feature, something that you would do with pretty much every feature you create for SharePoint. The next step is to add the feature receiver, our functionality is so simple that we can do this all from within a feature activated receiver.

To add the feature receiver, simply right click the feature and select Add Event Receiver.


This will generate a class file, it has several commented out methods that activate when different actions occur to our feature, right now we are only interested in the FeatureActivated one, so uncomment this.


Step 4: Add the Code!

We are now ready to add the code in to our feature receiver.

The first step is to get the Site Collection this feature is running on, and then the root web for that site collection. This can be accessed via the SPFeatureReceiverProperties as shown below.


The code we are going to add is going to go where I have left the comment. The using statements make sure any objects used are disposed when we are done.

As a recap we were looking to achieve three outcomes with this feature:

  1. Set the Locale of the site collection to Australia.
  2. Set the Search Centre to be /Search/Pages
  3. Set the Scopes Dropdown to be “Show scopes dropdown”

This is how we can achieve them:

  1. Set the Locale of the site collection to Australia.

  2. This piece of code simply sets the Locale of the web to a LCID of 3081 which is Australia. You can find a longer list of locales for your region here:

  3. Set the Search Centre to be /Search/Pages

  4. This value is simply a string stored in the property bag for the web.

  5. Set the Scopes Dropdown to be “Show scopes dropdown”

  6. The value for the scopes drop down is also stored in the property bag as a string, but there are a specific set, depending on what you want the value to be. If you take a look at the drop down you get the following values:


    The following values correspond with the drop down selection:

  • HideScopeDD – Do not show scopes dropdown, and default to contextual scope.
  • HideDD_NoScope - Do not show scopes dropdown, and default to target results page.
  • ShowDD – Show scopes dropdown.
  • ShowDD_DefaultURL – Show, and default to ‘s’ URL parameter.
  • ShowDD_DefaultContextual – Show and default to contextual scope.
  • ShowDD_NoContextual – Show, do not include contextual scopes.
  • ShowDD_NoContextual_DefaultURL – Show, do not include contextual scopes, and default to ‘s’ URL parameter

After this our entire block of code will look like the following, the extra code you will need is to execute the update statement:


You probably won’t write many feature receivers as simple as that, basically four lines of code plus setup, to achieve the three goals we had at the start. If you want to make sure your feature is having the desired affect before we continue, simply remove the hidden attribute, deploy to an existing site collection and activate the feature to see if it has the desired effect.

Note: I had some issues when updating the feature receiver, the web application was caching the old code, to get around this i simply ran an iisreset and it picked up the new code and ran as expected.