Wednesday, October 22, 2014

Step by steps on how to display Most Visited Sites with number of view count in SharePoint 2013 Web Analytics

Step by steps on how to display Most Visited Sites with number of view count in SharePoint 2013 Web Analytics 

It’s a backward step from Microsoft in terms of Web Analytics in SharePoint 2013 by removing the out of the box SharePoint Usage and Search Analytics reports that was provided with a more intuitive GUI in SharePoint 2010. This article shows you how to display most visited sites with view count in easy steps in SharePoint 2013

As you might have known by now that web Analytics is no more a Service Application and it is part of Search Service Application in SharePoint 2013.

Now there are few excel reports named as “Popularity reports” available in each list\library\Site and Site Collection in SharePoint 2013. It shows day/Month wise hit count of each document and list items in SharePoint 2013.But these reports in reality is not more effective and don’t present data needed to identify the effective usage of the SharePoint System. Also the SharePoint 2013 lacks the Web Analytics Web part that was available in SharePoint 2010.

You can now use the Content Search Web Part that is used to generate the Usage and Search Analytics. Content Search Web Part ships along with the Enterprise Edition of SharePoint 2013. When you activate the SharePoint Enterprise Site Features of a site collection you get the Content Search web Part available under the Content Rollup group in the Add Web Part section.

I will take a a examples of a report Most Visited Sites in SharePoint 2013 and explain how you can achieve using the Content Search Web Part which can be generated for a Site Collection, Web Application.

Note: You cannot generate any User Specific reports like “Top Visitors” or “Top Contributors” using the analytics component in SharePoint 2013 as it does not store any user specific data.

I will take a simple example of how to show “Most Visited Sites” in your Site Collection.
Most Visited Sites(With Content Search Web Part):

Make sure you have activated the “Cross Site Collection Publishing” feature activated in Site Collection Features for Content Roll Up section to appear in the Add Web Parts the To add a Content Search Web Part to your page.

Configure the content search web part using the below parameters
Edit the Content Search Web Part and Provide the below values for the properties of the Web part

1. Select “Change Query” Button. In the Basics Tab for Query window, Select the “Switch to Advanced Mode”.

Basics Tab
Local SharePoint Results
Use the below query text for Most Visited Sites:
(contentclass:STS_Web AND

Use the below query for Most Visited Documents


Note: The hit count of documents is recorded in
 Analytics component when the documents are 
opened using Office Web Apps in a Web Page.

Use the below query for Most Visited Pages:

AND (FileExtension:aspx or FileExtension:html)) 
(contentclass:STS_ListItem OR IsDocument:True)

Note: The above query only includes Pages
 content from libraries in the site and 
excludes any page that are available in
 the root folder of the site.
Sorting Tab
Sort By
ViewsRecent Descending (Orders the result set
 by ViewCount for last 14 days )


ViewsLifeTime Descending (Orders the result set
 by ViewCount from the time the Analytics Component
was enabled in the farm)

Click ok to Save the Query.

Calling a static "page method" from Javascript using MS AJAX

Calling a static "page method" from Javascript using MS AJAX

Atlas gave us the ability to easily call Web Services from JavaScript. MS AJAX has gone one step further! We can now call methods in the codebehine of the current page from Javascript. Here's how:
This is designed for v1.0.61025.0 of AJAXExtensionsToolbox.dll

Enable Page Methods on your ScriptManager

Set the EnablePageMethods attribute to true
<asp:ScriptManager ID="ScriptManager1" 
    EnablePartialRendering="true" runat="server" />

Mark your method as static and give it the WebMethod attribute

The method has to be declared static. It must also be marked with the WebMethod attribute. You'll probably find that you need to include System.Web.Services
using System.Web.Services;
public static string MyMethod(string name)
    return "Hello " + name;

Call it from Javascript

To call the method from javascript you need to append PageMethods. to the front of the method name.
    function test(){
        alert(PageMethods.MyMethod("Paul Hayman"));

Friday, October 17, 2014

Enable RSS feed in SharePoint 2013

Enable RSS feed in SharePoint 2013

SharePoint 2013 have out of the box support for publishing RSS feed for lists and libraries.  For publishing portals it is important to expose the site contents as RSS feeds. In this walkthrough I am going to explain how you can configure RSS feed for lists, libraries etc. in the SharePoint portal with your own display.

For the purpose of this walkthrough, I have created a picture Library named “MyPictures” and added five pictures to this library. The thumbnail view of the picture library is as follows.
Now go to the library tab of your list page.
You can see the RSS feed icon is disabled, this is because I didn’t enable the RSS feed for my site. Now let us see how we can enable the RSS feed settings.

Enable RSS feed for Sites/Site Collection

Initially you need to enable the RSS feed for the site collection and the site where you need to expose your contents as RSS feeds.
Go to your top level site settings page, if you are in a sub site, make sure you click on “Go to top level site settings”
Now In the Top level site settings page, you can find RSS link under site administration.
In the RSS settings page, you can enable the RSS for the site or entire site collection. Also you can define certain properties such as Copy right, managing editor, web master etc. Click OK once you are done.
If you want to disable the RSS feed for any site, go the site settings page and click RSS link and just uncheck the “Enable RSS” checkbox and click OK.
Now let us see the effect of the changes we have made. Go to the “MyPictures” page and under library tab, see the RSS icon, you should see the icon is enabled now.
Click on the RSS feed icon, you will see the RSS feed in the browser.

Customize the RSS feed

In SharePoint 2013, the RSS feed is exposed using listfeed.aspx, you can find the listfeed.aspx under the layouts folder.
By default the RSS feed is using RSSXslt.aspx file, which renders XSL to the browser.
You can find these files under layouts folder the 15 hive. The following is the path to layouts folder when SharePoint is installed in the C: drive.
C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS
Though it is possible to customize RssXslt.aspx to apply your own design, it is not recommended as this is a SharePoint system file and there is a chance that this file can be replaced by patches, service packs etc.
Though RSS feeds meant for machines, you may need to present the RSS feed in your site and provide subscription instructions. So you need to perform two things here, first you need to select the data for the RSS feed to expose and secondly you need to display the RSS feed in your site in a formatted way. Let us see how we can achieve the same.

Choose the data for RSS Feed

Navigate to your list page, under the library tab, click on Library settings icon.
Once you enabled RSS for the site, you will see a column “Communications”, locate “RSS Settings” under Communications.
Click on the RSS settings, you will see the below settings page
First you can define whether you need to enable RSS for this list, in case if you don’t want a particular list to expose as RSS feed, you can say no for this.
Under the RSS channel information; you can define a title, description and an Icon for the feed. Under document options, include file enclosures allows you to link the content of the file as encloses so that the feed reader can optionally download the file. Link RSS items directly to their files, since this is a picture library, I need the item to link directly to the image. You can select these options depending on your needs.
In the columns section, you can select the columns that you need to include in the RSS feed, also you can specify the order of the columns in the feed.
Under Item Limit, you can specify the maximum number of items and the maximum age for the item, by default items in the past 7 days will include, you can configure this based on your needs. Click OK once you are done.
See the output XML generated by listfeed.aspx

Display RSS feed in your page

Now you may need to include this RSS feed in your page. In order to do that you can use the XML viewer web part available in SharePoint 2013 and specify a XSLT for transforming the feed to formatted output.
First create a page and insert a web part, under the web part selection menu, select Content rollup as the category and then select the XML Viewer web part and click on the Add button.
In the Web part settings you can define XML url and XSL url.
The following is the output generated in the browser once I applied the attached xsl.


SharePoint 2013 supports exposing and consuming RSS feeds without writing a single line of code. You have complete control over on what content can be exposed as RSS feeds.

Monday, October 13, 2014

How to Remove the “Title” column from a SharePoint list

How to Remove the “Title” column from a SharePoint list

This is a short post about how to hide Title Column in Sharepoint list, I explained in another post how to reorder column in New,Edit,Display Form  ""

1.       In your list, click the List Settings button on the List tab.
2.       If the Content Types section isn’t visible, enable management of content types by following these steps:
·         Click the Advanced Settings link on the List Settings page.
·         Select the Yes radio button under Allow Management of Content Types? and then click OK. The Content Types section will be visible on the List Settings page.
3.       In the Content Types section of the List Settings page, click the Item content type.
4.       Click the Title column. Under Column Settings, select the Hidden (Will Not Appear in Forms) radio button and click OK.

Changing the order of fields in edit or display forms

Changing the order of fields in edit or display forms

Just a quick post in answer to a question I got yesterday:
How do you change the order of fields in edit or display forms?

It's a question a lot of end users struggle with, and I never know the answer without Google. So, I thought I'd put it up here, with some more relevant keywords, so others and I can find it more easily in the future.

1. Go to the list
2. Enter list settings (from the ribbon in 2010, from the drop downs in 2007)
3. Click Advanced settings
4. Ensure ‘allow management of content types’ is checked
5. Go back to the list settings
6. In the list of content types associated with the list, click the one you want to change the order of fields for (in lists that have been created ad hoc this is usually item or document). 
7. In the bottom of the screen a link appears called ‘Column order’ 

Hope it helps someone.

I explained in another post how to hide the title Field from Sharepoint list ""

Friday, October 10, 2014

SharePoint Custom Grouping with XSLT

Sharepoint Custom Grouping With XSLT

For SharePoint solution where the look and feel or clean code is very important we often create custom header.xslt ContentQueryMain.xslt and ItemStyle.xstl files. The files are almost completely empty to provide us with maximal control. This also means we need to recreate functionality that normally works by default. A good example is the ability to group the results.
1. Create the custom XSLT files and link the files to the Content Query Web Part.
2. The following code is a complete example of a custom Content Query Main XSLT file. This code generates grouping.

    exclude-result-prefixes="x xsl cmswrt cbq" 
    <xsl:output method="xml" indent="no" media-type="text/html" omit-xml-declaration="yes"/>

  <xsl:key name="Grouping" match="Row" use="@GroupingColumn" />

  <xsl:template match="/">
 <xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(.)=generate-id(key('Grouping',@GroupingColumn))]/@GroupingColumn">
  <xsl:sort />
        <xsl:value-of select="."/>
        <xsl:for-each select="key('Grouping', .)">
         <br /><xsl:value-of select="@Title" />
3. Change the XSLT where needed
CQWP Custom Grouping

Content Query Web Parts and the CommonViewFields Property

Content Query Web Parts and the CommonViewFields Property   

Much of my job as a SharePoint consultant working in the Web Content Management discipline is the configuring of web parts. One of the most popular web parts has to be the Content Query Web Part. This web part allows you to roll up different kinds of content at the site collection, site, or list level and have full control of the styling of the rollup list through XSL.
Although the Content Query Web Part is very easy to use, it can be challenging getting all of the information available which is what this blog article is all about. By default, fields such as Title, Descriptions, and URL are provided by default. The challenge arises when you need to display more information than what the default fields provide. An example of this would be the case where a custom date field, let's call it NewDate, would need to be included as part of the rollup.
Now, if we tried to call NewDate directly from the XSL, it would simply print out nothing. This is because the web part doesn't know about NewDate.
To do this, we need to configure the web part to tell it about our New Field.
This is a simple x step process.
  1. First, you will need to export the web part so that its properties can be edited.
    In edit mode on the CQWP, select Edit -> Export

  1. After opening the exported file, locate the CommonViewFields property.

    By default, it will be blank. Adding additional fields to this property will make them available for display.
  2. To continue with the example, we will need to add our new field, NewDate, to the CommonViewFields property. The format of this property is [Internal Field Name],[Data Type Name]. It is important to note that the name is the internal field name and not necessarily the name you gave to the list. The best way to determine the internal field name is to go to the List or Content Type settings and click on the new field. The internal field name will be the last query string argument in the URL.
    In our example, you would add "NewDate,DateTime" to the property as shown below:

    In this example, our field type is DateTime. For a complete list of field types, see this MSDN article:
  3. The final step is to save the web part file and import back into the page. The field, NewDate, is now available and can be successfully referenced in the appropriate XSL files.

How to export a schema.xml file for a list from a SharePoint site

How to export a schema.xml file for a list from a SharePoint site In sharepoint, we can retrieve the XML schema of any list by using ...