Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Posts Tagged ‘sharepoint 2010’

How to enable Performance Point Services?

Posted by Jean Paul on September 22, 2013

In this post I would take you through enabling Performance Point Services in SharePoint 2010.

What is Performance Point Services?

Performance Point Services is a Business Intelligence component of SharePoint 2010. It provides the following:

1. Dashboards

2. Score Cards

3. Key Performance Indicators (KPI)

The infrastructure is provided through service applications, a set of site/site collection features & associated web parts.

Additonally, the “Business Intelligence Center template not found” problem can be solved after enabling Performance Point feature.

What is the site template for creating Performance Point site?

The site template Business Intelligence Center.


Is the template available by default?

No! You need to enable the following features:

1. Performance Point Services

2. Server Side Publishing

The features should be enabled in the site collection & site level.

Central Administration

We need to provision the Performance Point Services in order to enable the feature.

Open Central Administration > Manage Service Applications > Performance Point Services > Secured Store Account


You might need to configure the Secured Store services as well.

Enable Features

Open the Site Collection Features & Activate the following features.



Repeat the same for Site Features as well.


You can try creating a new site from template Business Intelligence Center.




In this article we have explored how to enable Performance Point Services in SharePoint 2010.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Programmatically Refresh Content Query Web Part

Posted by Jean Paul on September 17, 2013

In this article we can explore a real life scenario of refreshing Content Query Web Part programmatically.


I hope the reader is having good knowledge of:

1. SharePoint page editing

2. Web Part insertion

3. Web Part creation using Visual Studio

4. Web Part Deployment


Following are the scenario items:

1. A home site with 2 web parts, project button web part & Content Query (CQ) web part

2. 2 project sites, each with Tasks list

3. On click of button, the particular project tasks should be shown in the CQ web part

How to achieve the same?


What is Content Query web part?

Content Query web part allows list querying & it is a part of Enterprise Content Management (ECM) functionality. You can add the web part from the Content Query category. You need to enable the Publishing feature to access the web part. Within code, the web part is called Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart

Step 1: Create Project Sites

Create 2 project sites of template Team Site & add some tasks into it. Make sure you remember the URLS.

The Project 1 Tasks list:


The Project 2 Tasks list:


Step 2: Design Project Buttons web part

Open Visual Studio & Perform the following:

1. Create a new Visual Web Part project of type Farm Solution

2. Add reference to Microsoft.SharePoint.Publishing namespace

3. Delete the existing web part inside the project

4. Create a new Visual Web Part & name it as ProjectButtonsWebPart

5. Replace the Page Load event with following code.

private static Dictionary<string, string> _projectUrl;

protected void Page_Load(object sender, EventArgs e)


_projectUrl = new Dictionary<string, string>();

_projectUrl.Add(“Project 1”, “/projectsite1”);

_projectUrl.Add(“Project 2”, “/projectsite2”);

// Create UI controls for Projects

foreach (string project in _projectUrl.Keys)


Button button = new Button();

button.Text = project;

button.Click += button_Click;




6. Add the following method for button click event handler.

private void button_Click(object sender, EventArgs e)


string url = _projectUrl[(sender as Button).Text];

SPSite site = SPContext.Current.Site;

SPWeb web = site.RootWeb;

web.AllowUnsafeUpdates = true;

SPLimitedWebPartManager manager = web.GetLimitedWebPartManager(“SitePages/Home.aspx”, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

foreach (System.Web.UI.WebControls.WebParts.WebPart w in manager.WebParts)

if (w is Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart)


Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart cwp = (w as Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart);

SPWeb targetWeb = site.OpenWeb(url);

cwp.WebUrl = targetWeb.ServerRelativeUrl;

//set the guid of the list

cwp.ListGuid = targetWeb.Lists[“Tasks”].ID.ToString();

PublishingWeb pweb = PublishingWeb.GetPublishingWeb(targetWeb);




ClientScriptManager cs = Page.ClientScript;

String csName = “ReloadClientScript”;

Type csType = this.GetType();

if (!cs.IsStartupScriptRegistered(csType, csName))


StringBuilder csText = new StringBuilder();

csText.Append(“<script type=”text/javascript”>”);

csText.Append(“this.location.reload(); </”);


cs.RegisterStartupScript(csType, csName, csText.ToString());



7. Ensure you have the following namespaces included.

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Publishing;

using Microsoft.SharePoint.WebPartPages;

8. Resolve any namespace issues like System.Web.UI.WebControls.WebParts.WebPart

9. Build the project

10. Deploy the project

11. Insert the Project Buttons web part to the home page. It looks like below.


Step 3: Insert the Content Query web part

Now we can insert the Content Query web part into the home page. Open page in edit mode & insert web part from the Content Rollup group as shown below.


Edit the web part & make the Presentation > Link property as empty.


Now the page looks like:


Step 4: Test the buttons

Now click on the Project 1 button & you should see the Content Query web part updated with tasks.


Now click on the Project 2 button & you should see the tasks changed with Project Site 2.


To summarize the activities, please note the following:

1. The Project Buttons web part have 2 hard coded paths inside it

2. On click of the button, the Content Query web part is refreshed by changing the List ID property

3. After the button click is processed, a client side startup script is registered to reload the page

4. Now on clicking the button, the content query web part will display tasks list from the corresponding project site.



In this article we have explored a typical real world scenario of refreshing a web part from another web part. I hope this will be useful to you in SharePoint development.

The source code can be downloaded here.

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , , , , | Leave a Comment »

Create Site Collection with New Managed Path, Content Database

Posted by Jean Paul on July 14, 2013

In this article I would like to share the PowerShell script which performs the following:

1. Create new content database

2. Create new managed path

3. Create new site collection

PowerShell Script

Following is the PowerShell Script which performs the same.

# Add Snapin

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )


Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell


# Create Content Database

New-SPContentDatabase -name “DATABASE-NAME” -WebApplication “http://WEB-APP-URL&#8221;

# Create Managed Path

New-SPManagedPath -RelativeURL “path/subpath” -WebApplication “http://WEB-APP-URL&#8221; -Explicit

# Create Site Collection

New-SPSite http://WEB-APP-URL/path/subpath -OwnerAlias DOMAINuser -Name “Site Collection Title” -Template “STS#0” -ContentDatabase “DATABASE-NAME”


You can verify the new site using the URL:


You can verify new managed path through Central Administration >Main Page > Select web application > Managed Paths (toolbar item)


You can verify the new content database through Central Administration > Main Page > Manage Content Databases link.



The same PowerShell script will be added to PowerShell Repository.  Please give me some time to do it.


In this article we have explore the PowerShell script to create new site collection with new managed path & content database.  I hope this will be useful for site conversion activities.

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , , | Leave a Comment »

How to Delete a Managed Path?

Posted by Jean Paul on July 14, 2013

Imagine that you created a wrong managed path.  How to delete it?

  1. We can delete using Central Administration
  2. We can delete using PowerShell
  3. We can delete using Server Object Model

In this post, I will show how to delete a managed path using Central Administration.

Open Central Administration

Open Central Administration & Open Manage Web Applications link as shown below:


In the appearing page, select the web application, click the Managed Paths button as shown below:


You will get the following dialog:


Select the path, then click the Delete selected paths link from the top.  Your link is deleted.

Click the OK button to close the dialog.


In this post, we have explored how to delete a managed path.

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , | Leave a Comment »

Content Type – Advantages, Creation, Association

Posted by Jean Paul on July 14, 2013

In this article I would like to reveal the advantages of Content Type in real world scenarios.

What is Content Type?

A content type is a reusable collection of metadata (columns), workflow behavior and other settings for a category of items or documents.


We can manage Content Types through the Site Actions > Site Settings > Content Types page.

Advantages of Content Type

Reusability: We can create a content type & reuse across the site. For example, we can create a content type named Expense & reuse it in multiple departments like HR, Marketing, Research etc.


Additional to columns, we can reuse the workflows, custom forms associated with Expense content type. The reusability feature helps in reducing time effort in creating redundant items.

Standardization: Content Type allows quick standardization of items through definition in one place.

Centralized Control: We can apply changes to existing content type & the associated list or library will reflect changes automatically.

For example, if we add a Description column to the above Expense Content type, the change will be reflected in all associated libraries.

Another example, we can create custom new/edit forms for a content type & the changes should reflect everywhere. So, quick standardization is possible through content type.

Default Content Type: We can add a new content type to a library or list & make it default. Default Content Type will be invoked while using the Add Document or Add Item links.

Multiple Associations: We can associate multiple content types to a list or library. For example a Project Library can have different content type associated like: Plan, Expense, Meeting, Discussion etc.

Creating Content Type

In this step, we can quickly create a content type. Open Site Actions > Site Settings > Site content types link as shown below:


In the appearing page, click the Create button.


You should get the screen below to enter the Content Type detail. You can create a content type inheriting from existing content types like Item, Document, Folder etc.

For the time being, please select the Item content type from List Content Types group. Enter the name of new content type as Expense.


Click OK button to save changes. You can see the new content type created in the content types page, make sure you check under the Custom Content Types group.


You can edit the above Content Type & add remaining columns Amount, Date & Person.


Now we are ready to associate the above content type to a List. As we have created a List Content Type, we can associate it with List. (for library, we need to create Document content type)

Open an existing List & choose List Settings. From the Advanced Settings, check the option Allow Management of content types.


Coming back to the List Settings page, choose the Add from existing content type link.


In the appearing page, you can select our Expense content type & click the Add button.


After clicking Add button, click Ok button to continue.

Now you are ready to use the new content type. Go to the List, click the New drop down, You can see the Expense item listed there.


We can make a content type as Default which will set the New command to the specified item.

On clicking the Expense item, you can see the dialog box with Expense fields.



Please note that wise usage of Content Type, in the long run, should save Time, save Effort and increase Quality of Content Management.



In this article we have explored Content Type, Advantages, Creation and Association.

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , | Leave a Comment »

Associate Metadata with Library

Posted by Jean Paul on July 12, 2013

In this article I would like to demonstrate association of Metadata with a Library.


This article assumes that you already have Terms created using the Term store management tool. Now you are going to associate the same with a document library.

Site Actions > Site Settings > Term store management


For creating Term Set, please contact the appropriate site collection administrator.

Open Document Library

Open Library Settings > Create column link as shown below:


In the appearing page enter the column name, Term for example & choose type as Managed Metadata.


Scroll down the page & from Term Set Settings section, choose the Term Set.


Click the Ok button to save changes.

Good! You are ready with Term Set associated with the library.

Entering Data

Now you can try entering data along with the Term. Try uploading a new document to the library & you will be prompted with the term input.


You can select the term from a dialog, or type for auto-completion.

After saving the changes, you can see the term in the list view.


Allow Multiple Terms for a Column

In order to allow multiple terms for a column, in the column settings page, choose the option



Associating Terms along with document, items improve the Content Classification resulting in improved search, key filters.



In this article we have explored how to associate metadata with a Library.

Posted in SharePoint 2010 | Tagged: , , , | Leave a Comment »

Layout Problem after Import Site

Posted by Jean Paul on July 9, 2013

In this article I would like to explain a problem I faced after import & the solution.


I was converting a site to site collection using PowerShell commands.

The source site was: http://server/site

The destination site collection was: http://server/newsite

Please note that the URLs are same in this case.


After the import, one of the sub sites having Publishing Pages inside it throws Layout Error as shown:


Error Message: This page is not using a valid page layout. To correct the problem, edit page settings and select a valid page layout.

Root Cause

This is a bug within Exported Sites where the parent site layout master-page url is hard-coded inside the publishing page. There is no way to change it through SharePoint user interface.



You can try one of the following solutions:

1. Use the PowerShell in following link to update the page with correct master page URL link

2. Use the C# code in following link to update the page with correct master page URL link

3. Modify the page manually

Modify the Page Manually

In my case the first 2 options did not worked, then I downloaded the file, modified it, uploaded back & the problem was resolved.

Please follow the following steps:

Step 1: Download File

Open the Pages library of the affected page. You can use direct URL as given below:


In the appearing page choose the Pages library and download the Default.aspx page. (Choose item context menu, Send To > Download a Copy button)

Step 2: Modify File

Open the ASPX file & locate the section <mso:PublishingPageLayout>. A sample text is given below:

<mso:PublishingPageLayout msdt:dt=”string”>/_catalogs/masterpage/WelcomeLinks.aspx, Welcome Links</mso:PublishingPageLayout>

Please note that the link is pointing to the root site, in my case it should point to the new site collection. So I will change the URL: /_catalogs/masterpage/WelcomeLinks.aspx

To new URL: /newsite/_catalogs/masterpage/WelcomeLinks.aspx

Step 3: Upload File

Now upload the file back to the same library & overwrite existing one. Make sure you check in the changes.

Step 4: Retest Page

Now go back to the browser, clear the cache & retry the problem sub site. This time you should see the Page is working correctly.


You need to ensure that the Publishing feature is enabled in the newly created site collection & site. Additionally make sure the master pages are valid. You can see master pages through url _catalogs/masterpage.



In this article we have explored a possible After-Import problem & the Solutions.

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , , | 2 Comments »

Error : Unable to Delete Site : SharePoint 2010

Posted by Jean Paul on June 28, 2013

I was working on a site moving, but the operation failed due to site template mismatch.  I ended up with a half-created site.

I can access the site through URL, but unable to access the site settings to delete the site.


I tried PowerShell Remove-SPSite approach, but it says it cannot find the site with url.


I tried to examine the problem using Squadron.  Luckily i was able to see the site there.  Then the rest is easy – created on Delete command which recursively delete sites & sub sites under.  It worked like a charm with Squadron.


Here are the steps involved to delete a site collection/site/list/library using Squadron.

Install Squadron

You can download the latest from

Install the application & run it from Start Menu > Programs > Squadron


Open the Explorer plugin from the left pane.


Locate the site to be deleted


Click the Delete button


Confirm site deletion


Great! Your defective site should be deleted now.


Here we have explored a rare scenario of defective site & deletion of it using Squadron.  You can use the tool for site collection deletion, list/library deletion as well

Posted in SharePoint | Tagged: , , , , | Leave a Comment »

SharePoint 2010 – How to get Farm Servers through code?

Posted by Jean Paul on June 27, 2013

In this article we can explore the following code:

· Retrieve Name & Type of all Servers in the Farm


A SharePoint Farm consists of multiple servers with role associated to each. For example a typical 500 user Farm can contain:

1. Web Front End Server

2. Application Server

3. Database Server

4. Email Server

5. Searcy Index Server

Following is a typical output from a Server Farm.



Here we are using Server Object Model code to retrieve the farm information.

For getting Farm instance, we can use the SPFarm.Local property.

using Microsoft.SharePoint.Administration;

SPFarm farm = SPFarm.Local;

For iterating through the servers, we can use the Servers property of Farm object.

foreach (SPServer server in farm.Servers)



For retrieving the Name, Role, Type we can use the instance properties of SPServer.

· server.Name

· server.Role

· server.TypeName

Following is the console application code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Administration;

namespace EnumFarmServers


class Program


static void Main(string[] args)




SPFarm farm = SPFarm.Local;

foreach (SPServer server in farm.Servers)












Central Administration

We can always retrieve this information from Central Administration as well.


The console application source code is attached.


Please note that the above code is integrated with Squadron (Free Administration Tool for SharePoint)


You can download the tool from:



In this article we have explored the C# Server Object Model code to retrieve Farm Server Information. In the real world scenarios we can use this information to quickly understand the server topology.

Posted in SharePoint, SharePoint 2010 | Tagged: , , | Leave a Comment »

Error :: Cannot start service UserCodeV4!

Posted by Jean Paul on June 10, 2013

Scenario: While deploying solutions using Visual Studio, we may encounter the following error.

Error: Cannot start service UserCodeV4 on computer ‘COMPUTER-NAME’


Description: The service mentioned here is SharePoint Service, not Windows Service. 

Solution: Open Central Administration > Manage Services on Server link


You will get the following page of SharePoint Services.


Among the services locate the Microsoft SharePoint Foundation Sandboxed Code Service, it should be having status Stopped.


Click the Start button to restart the service.

Now, back in your Visual Studio try Deploy operation again.  You should succeed this time.

Posted in Uncategorized | Tagged: , , , , , , | Leave a Comment »