Blog of Sundar Narasiman

Restrictions in SharePoint 2010 Sandboxed Solution – Part1

We all know that SharePoint 2010 Sandbox Solution is restricted and it has access to only the subset of functionalities available in Microsoft.SharePoint namespace. In this article, we’ll see restrictions imposed by Sandboxed solutions. Basically, the calls made by Sandboxed solution are routed through subset proxy, which in turn makes the calls to the full object model. In this case, the subset proxy brings in the restriction by exposing limited set of functionalities. Here is the list of API exposed by subset proxy.






All of the Microsoft.SharePoint namespace except the following


a)SP Site Constructor

b)SP Security Object

c)SPWorkItem and SPWorkItemCollection objects

d)SPAlertCollection.Add method

e)SPTransformUtilities Object

f)SPUserSolution and SPUserSolutionCollection objects




All of the Microsoft.SharePoint.Utility namespace except the following :-


a)SPUtility.SendEmail method




All of Microsoft.SharePoint.WebPartsPage

Except the following


a)SPWebPartManager object

b)SPWebPartConnection object

c)WebPartZone Object

d)WebPartPage Object

e)ToolPart object

f)ToolPane Object


If we examine the restrictions carefully, we can infer that the capabilities of the core foundational object model is available in the Sandboxed Solutions. However the advanced capabilities like Search, BCS, Access Services and Excel Services are restricted.

Next, we’ll see what are all the SharePoint 2010 Project types supported by Sandboxed Solutions.


SharePoint projects supported by sandboxed solution

SharePoint projects not supported by sandboxed solution


Content Types / fields


Modules / files

Application pages


List definitions

Web application scoped features


List instances

Custom action group


Site definitions

HideCustomAction element


Web Template Features

Content type binding


Web parts (non-visual)



Feature Callouts



Declarative workflows



Custom actions












Here are few more restrictions. The code inside Sandboxed solution cannot perform the following operations:-

a) Cannot read/write to the file system

b) Cannot call the network

c) Cannot write to the Registry

d) Cannot call assemblies deployed out of Global Assembly Cache

The next part of the article would cover the CAS policy restrictions on Sandboxed solution


At this point of time, the Visual Web Parts can be created as Sandboxed Solutions with the help of Visual Studio Power Tools for SharePoint.


 Subscribe to my blog

India Wins World Cup Cricket after 28 Years

Today is a very special day in the history of Indian Cricket. Yes, the Indian Cricket Team have Won the cricket world cup after 28 years. We have done it again. This makes us (all of the Indians) really proud. Another crown for the little master in his cricketing Journey. Kudos to Dhoni & Co, special mention to Yuvraj Singh and no words to describe the genius of little master Tendulkar.

Team India have made this country proud again.

What a moment for die-hard cricket fans ?

Pic01 Pic02 Pic03
Pic04 Pic06 Pic07
Pic08 Pic09 Pic11

Replace SharePoint 2010 Search Box using Delegate Control

The Delegate Controls comes into picture when want to brand a SharePoint Site. The delegate control acts like a container control which encapsulates default content (set of child controls inside it). The default content (set of child controls associated with delegate) can be substituted by a specific control, by creating a feature. The ability to override or substitute the delegate controls brings the power & flexibility to brand SharePoint Sites.

The out-of-box SharePoint Foundation Master Page defines many controls like Top Navigation Data Source, Left Navigation Data Source, Search Box and Additional Page Head etc as delegate controls. The list is illustrated below :-

<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" 
<SharePoint:DelegateControl runat="server" ControlId="GlobalNavigation" />
<SharePoint:DelegateControl runat="server" ID="GlobalDelegate0" ControlId="GlobalSiteLink0" />

<SharePoint:DelegateControl ControlId="GlobalSiteLink2" ID="GlobalDelegate2" Scope="Farm"
 runat="server" />

<SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" 
</SharePoint:DelegateControl><SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" 
runat="server" />
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4" />

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" 

The above listed delegate controls can be substituted at runtime to achieve custom branding. Let’s try to replace the Small Search Input box and see how the delegate control helps for this process. The whole idea is to define a feature for the Custom User Control with same control id mentioned in delegate and the lowest possible sequence number.

Here are the steps below :-

File —> New Project —> Empty SharePoint Project


Right Click Project –> Add New item –> User Control . Name it as ‘ReplaceSearchBox’


It automatically creates control templates folder and places the user control underneath that. Create any arbitrary control inside the user control. For the illustration purpose, I’ll add a Calendar Control inside the user control, to visually show a difference how the page looks after the delegate substitution.

<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
It automatically creates control templates folder and places the user control underneath that.

Right Click Features –> Add Feature

Set the Feature Scope at Site (site-collection level)

Right Click Solution —> Add New Item –> Empty Element

We’d be leveraging Elements.xml file for the delegate substitution process. Before jumping on to the substitution lets understand how the out-of-box Search Box is defined using Feature.


The Search Box is defined in both the Features ‘OSearchBasicFeature’ and ‘OSearchEnhancedFeature’ in the location 
C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEFEATURES
The definition looks like the following :-
<Elements xmlns="">
ControlAssembly="Microsoft.Office.Server.Search, Version=, Culture=neutral, 

    <Property Name="GoImageUrl">/_layouts/images/gosearch15.png</Property>
    <Property Name="GoImageUrlRTL">/_layouts/images/gosearchrtl15.png</Property>
    <Property Name="GoImageActiveUrl">/_layouts/images/gosearchhover15.png</Property>
    <Property Name="GoImageActiveUrlRTL">/_layouts/images/gosearchrtlhover15.png</Property>
    <Property Name="DropDownMode">ShowDD</Property>
        <Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>
    <Property Name="ScopeDisplayGroupName"></Property>
    <Property Name="FrameType">None</Property>
<Elements xmlns="">
Here the Id & Sequence number of the control plays an important role. 
To substitute this out-of-box SmallSearchInput box, Let’s define Elements.xml file for Feature. The id of the control should match with id of control to be replaced. 
The Sequence number should be less than the sequence number of the out-of-box control. In this case we’re assigning sequence number as 10, so that the control with the lowest
 sequence number gets precedence.
    <Control Id="SmallSearchInputBox" Sequence="10"
      ControlSrc ="~/_controltemplates/ReplaceSearchBox/ReplaceSearchBox.ascx">        
Since we’re using an user control for substitution, we need to make sure that ControlSrc attribute is defined. There is no need to define ControlClass and ControlAssembly attribute here. 
I did define all the 3 attributes, but the substitution was not happening. I’ve learnt that it’s enough to define the ControlSrc attribute itself. Do not define all 3  attributes for user control, 
the substitution will not happen. If you are using Custom Control, it makes sense to use ControlClass and ControlAssembly attribute.
The final Solution Package looks like the following :-

Build the Project, Package it and Deploy.

Now you can see the the custom user control with Calendar replaces the Delegate control.

Delegate Substitution


 Subscribe to my blog

Recycle IIS Application Pool: Cannot connect to the SharePoint site

I created a Visual Studio 2010 SharePoint Project. When i tried to build and deploy the solution from Visual Studio, i got the following error :-

Error occurred in deployment step ‘Recycle IIS Application Pool’: Cannot connect to the SharePoint site: http://samplesite/. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.

I realized the i’m not the administrator of the box and also did not have the access to the SharePoint content db. I fixed this issue by doing the following :-

1. Added myself as the administrator

2.Added myself to SharePoint Farm Admin Group

3. Provided DB Owner access to SharePoint Content DB


 Subscribe to my blog

SharePoint Webcasts for January 2011

I tried to collate the list of SharePoint web casts that are scheduled for January 2011. They are listed below :-

1. How to use Team Foundation Server to Manage the SharePoint Life Cycle

1/6/2011 12:00 PM Mountain Time (US & Canada)

2. How to use Team Foundation Server to Manage the SharePoint Life Cycle

1/20/2011 12:00 PM Mountain Time (US & Canada)

3. MSDN Webcast: SharePoint Ecosystem: SharePoint Online – Developing Solutions for the Cloud (Level 200)

1/11/2011 9:00 AM Pacific Time (US & Canada)

4. TechNet Webcast: Search-Driven Internet Sites: Increase Relevancy, Lower Overall Costs (Level 200)

1/11/2011 1:00 PM Pacific Time (US & Canada)

5. Business Insights Webcast: Search and Community Experiences with SharePoint Server for Internet Sites (Level 100)

1/19/2011 11:00 AM Pacific Time (US & Canada)

6. MSDN Simulcast Event: SharePoint FireStarter

1/27/2011 8:30 AM Pacific Time (US & Canada)

7. TechNet Webcast: Using Office and SharePoint to Take Control of Marketing Spend and ROI (Level 100)

1/25/2011 1:00 PM Pacific Time (US & Canada)

 Subscribe to my blog

Develop Custom Workflow Activity for SharePoint 2010 Workflow

In this article, I’d be discussing the steps to create a custom workflow activity for SharePoint 2010. The need for custom workflow activity arises, when the out-of-box workflow activities do not suffice our requirement. The functionality of developing a custom activity for SharePoint 2010 Workflow is not a new feature in SharePoint 2010. This was available in SharePoint 2007, which is now continued to SharePoint 2010. Once the custom workflow activity is created, it can be made available for use inside SharePoint Designer 2010.

File —> New Project

Select —–> Visual C# —> SharePoint | 2010 —-> Empty Project

custom activity 1

custom activity2



Click Finish

File —> Add –> New Project

Select the Visual C# | Workflow | Workflow Activity Library and set the project name as ‘CreateActivityDemo’.

custom activity3[5]

Right click ‘CreateActivityDemo’ project and add a reference to Microsoft.SharePoint.dll and Microsoft.SharePoint.Workflow.Actions.dll

Add a new workflow activity called ‘CreateSurveyLibrary.cs’

Switch to view code of ‘CreateSurveyLibrary.cs’

Import the following namespaces

using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.Workflow Actions;
Add a dependency property property by name ‘SiteUrlProperty’
 public static DependencyProperty SiteUrlProperty = DependencyProperty.Register("SiteUrl", 

typeof(string), typeof(CreateSurveyList), new PropertyMetadata(""));
        [DescriptionAttribute("Url of site where survey is to be created")]
        public string SiteUrl
                return ((string)(base.GetValue(CreateSurveyList.SiteUrlProperty)));
                base.SetValue(CreateSurveyList.SiteUrlProperty, value);

The SiteUrlProperty is used to capture the url of the site, in which the survey list needs to be created. The convention for creating the dependency property is to have the keyword ‘Property’ appended (at the end) to the name of the actual property. In this case, the name of the regular C# property is SiteUrl, the dependency property is created with convention of ‘SiteUrlProperty’. If this naming convention is not followed, we’ll get a compilation error.

Add another dependency property called ‘SurveyListNameProperty’. This is used to assign the name for Survey List during the list creation.

 public static DependencyProperty SurveyListNameProperty = DependencyProperty.Register("SurveyListName", 

typeof(string), typeof(CreateSurveyList), new PropertyMetadata(""));
        [DescriptionAttribute("Name for survey list")]
        public string SurveyListName
                return ((string)(base.GetValue(CreateSurveyList.SurveyListNameProperty)));
                base.SetValue(CreateSurveyList.SurveyListNameProperty, value);
Again, follow the same naming convention for creating this dependency property ‘SurveyListName’, discussed above.

The next logical step in creating custom workflow activity for SharePoint is to override the Execute method of the workflow activity. Then add the relevant logic to the Execute method for creating a Survey List in the specified site with the specified survey list name.

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
            return ActivityExecutionStatus.Closed;
        private void CreateSurveyLibrary()
            using (SPSite oSPSite = new SPSite(SiteUrl))
                using (SPWeb oSPWeb = oSPSite.RootWeb)
                    Guid ID = oSPWeb.Lists.Add(SurveyListName, SurveyListName + System.DateTime.Now.ToString(),
                    SPList oSPList = oSPWeb.Lists[ID];
                    oSPList.OnQuickLaunch = true;

Create a strong name for the assembly ‘CreateActivityDemo’.

Right click on the CustomWorkflowActivityDemo project and Add —> SharePoint Mapped Folder

Navigate to Template1033Workflow and Select it.

custom activity4

Create an XML file called ‘CreateActivityDemo.Actions’ under the workflow folder. Complete the definition of ‘CreateActivityDemo.Actions’.The definition of ‘.Actions’ file is responsible for making the custom workflow activity appear in the SharePoint Designer 2010.
  <Actions Sequential="then" Parallel="and">
    <Action Name="Create Survey List"
        Assembly="CreateActivityDemo, Version=,
           Culture=neutral, PublicKeyToken=38b1d60938e39f46"
        Category="Sundar Activity">
      <RuleDesigner Sentence="Survey List Name %1 to site %2.">
        <FieldBind Field="SurveyListName" Text="Survey List Name"
           DesignerType="TextArea" Id="1"/>
        <FieldBind Field="SiteUrl" Text="Url of base site" Id="2"
        <Parameter Name="SurveyListName" Type="System.String, mscorlib"
      Direction="In" />
        <Parameter Name="SiteUrl" Type="System.String, mscorlib"
      Direction="In" />


Next, we need to add the assembly for custom workflow activity in the Package.

Double click on the Package.package

custom activity5
Click ‘Advanced’ in Package Designer.
Add a Safe Control for Workflow Activity Assembly ‘CreateActivityDemo’.
custom activity6
Create an authorized type entry for the CreateActivityDemo assembly (custom workflow activity assembly).
<authorizedType Assembly="CreateActivityDemo, Version=, Culture=neutral, PublicKeyToken=38b1d60938e39f46" Namespace="CreateActivityDemo"
 TypeName="*" Authorized="True" />
Deploy the Solution. Now we’ll see the custom activity ‘Create Survey List’ appearing in the SharePoint Designer 2010 under actions.

custom activity7



The custom workflow activity  ‘Create Survey List’ is ready to be tested.


Create a re-usable workflow and drop the ‘Create Survey List’ activity.


Set the Values for SiteUrl and SurveyListName.

custom activity8[5]


Start the Workflow.


custom activity 9


Now the Survey is created in the site with defined name.


custom activity 10

This completes the development of custom workflow activity.

 Subscribe to my post

Create SharePoint 2010 workflow using SharePoint Designer

In this article, I’d be discussing about the creating SharePoint 2010 workflows using SharePoint Designer 2010. Rather than designing a workflow from scratch, I’d be re-using the workflow defined in Visio (Refer previous article).

Before getting into the workflow, I’m defining a content type by name ‘Invoice Report’ with three basic site-columns InvoiceAmount, Invoice Date and InvoiceDepartment to keep it simple.

site columns

content type

 Create a new custom list by name ‘Invoice’ and attach the content type ‘InvoiceReport’ to it.


Navigate to Site Objects –> Workflow in SharePoint Designer

import from visio1[6]

 Choose ‘invoice processing.wvi’ (workflow designed in the previous article) and click Next. 

import from visio2

Choose ‘Reusable workflow’ as type of workflow (in this case i want this workflow to be re—used across lists that has associated invoice report content-type).

import from visio3

Click finish.

The workflow will look like the following in the designer.

workflow designer

Go to step ‘Log for starting’ and change the message to ‘workflow is starting’’.

Go to If  statement under step ‘Invoice > 50K’ and define the expression like if Invoice Amount less than or equal to 50,000.



Set Workflow status to Approved under If loop.


Under log for Auto Approval, set the message ‘Workflow is Auto Approved’.


Go the Else part and configure the Task Approval process. 

approval config

In this case, the Task Approval process will be executed if the invoice amount is greater than 50,000. The idea is to enforce a manual task approval process, approved by the manager.

The workflow design would look like the following:-

final workflow design

If you choose Custom Approval Process or Custom Task Process, you’ll get bunch of actions to customize the behavior of the single task or task process.

task behavior1

task behavior2

The Task Behavior Actions is one of the improved feature in SharePoint 2010 workflows. The Task behavior actions does not appear in Visio 2010, when you design workflows . It is available in SP Designer 2010 and VS 2010. The actions like Escalate Task may find a common usage. But in this case, I’m not customizing any task behavior, just sticking with the task behavior defined for the Approval Process in SP Designer 2010.

Check for errors and publish the workflow.

Go to the SharePoint site and associate the Invoice Processing workflow with the invoice list.

Under workflow settings –> Add a workflow

Set content type to ‘Invoice Report’

Select ‘invoice processing’ under the workflow template

Set ‘Department Invoice workflow’ for the unique name of the workflow.

Set the workflow to be started manually

workflow setting

Create an invoice item in the list.

invoice new item

Start the workflow manually.

The invoice item would be approved, because the amount is less than 50K.


Let’s try with another invoice amount of 60, 000.

Start the workflow again.

Now the workflow is not auto-approved, task is assigned to the Manager and it is in progress state.

Log in as Manager to see the assigned Task.

task approval

Click ‘Approval’ button to approve the invoice.

We’ve created a very simple workflow in SharePoint Designer 2010. I’ll deal with more advanced workflow scenarios in the next articles.

 Subscribe to my post

Design SharePoint 2010 workflows in Visio 2010

I thought of writing a series of articles around SharePoint 2010 workflows.  This is one of my favourite area in SharePoint 2010 and  I’m also involved in lot of  SharePoint 2010 workflow development these days. Microsoft Visio 2010 Premium edition has the ability to design SharePoint 2010 workflows using the visual designer and export it to SharePoint Designer 2010 (and then to Visual Studio 2010) for further implementation. This brings powerful workflow modelleing capability to the business users and also brings consistency during workflow modeling and workflow implementation.

The business users/power users can start modeling the business process in Visio 2010 and then transition this to the development team for further implementation. The workflow modeling in Visio 2010 needs a bit of understanding of SharePoint 2010 platform. At this point of time, the SharePoint 2010 workflow modeling capability is not supported in Professional edition of Visio 2010.

 Let’s open the Visio 2010

File —-> New —> Microsoft SharePoint Workflow —> Click ‘Create’

We’ll get to see three tabs SharePoint Workflow Actions, SharePoint Workflow Conditions and SharePoint Workflow Terminators. 


SharePoint workflow terminators has the activities for start and terminate of workflow.


SharePoint workflow conditions has the set of activities to perform various conditonal checks like comparing against arbitrary parameters, comparing with the current list items and  check for other SharePoint related objects.


SharePoint workflow actions has the whole lot of actions that can be performed related to a SharePoint workflow.


If we do quick tour of activities present in Visio 2010, we feel most of these are available in SharePoint Designer 2010. Yes, SharePoint Designer 2010 and Visual Studio 2010 has lot many activities. I’ll brief the in later sections of that article. Let’s move on the the business process, that we want to model in Visio 2010. It’s a simple one.  Let’s assume that we’re modeling an Invoice process for a contracting form.  The contracting firm (vendor) submits invoice to the company ‘A”. If the invoice is less than 50K, the invoice would be approved. A manual approval process is needed if the invoice exceeds 50k.

Let’s try to model this.. 

1. Drag the ‘Start’ activity from the workflow terminators

2. Drag ‘Log to History’ from Workflow Actions and connect with the ‘Start’ activity. Double click the activity and name it as ‘Log for starting’

3. Drag ‘Compare Data Source’ activity from workflow conditions and connect it with ‘’Log to History’ activity.  Double click and rename the activity as ‘If invoice > 50k’

4. Drag ‘Set Workflow status activity’ . Connect it with the compare data source activity (‘invoice > 50k’). Double click and rename the activity as ‘Auto Approval’. Right click on the connector line and set it as ‘Yes’.

5. Drag ‘Start approval process activity’ to the other side of the compare data source activity (‘invoice > 50k’) and connect it. Double click and name it as ‘Manager approval process’. Right click on the connector and set it as ‘No’

6. Drag a ‘Log to History’ next to ‘Auto Approval’ and double click and name it as ‘Log for Auto approval’. Connect it with Terminate activity.



Navigate to the Process Tab in the Ribbon and click ‘Export’


Save the workflow definition as ‘invoice processing.vwi’.

Now the workflow is ready for implementation in Microsoft SharePoint Designer 2010.


We’ve included the manual ‘Approval Process’ if the invoice > 50 K . This involves task process. The task behavior cannot be customized in Visio 2010 to include more custom task behavior actions like Wait for Change in Task Process, Wait for Deletion in Task Item Process and Escalate Task etc. This can be customized

I’ll discuss about implementing this workflow in SharePoint Designer 2010 in the next article.

 Subscribe to my post

Visio 2010 does not show option to create SharePoint 2010 Workflows

I’ve installed the Visio 2010 Professional and tried to design SharePoint 2010 workflow. Surprisingly, i did not get the option to design SharePoint 2010 workflow.


I’ve learnt that Microsoft Visio Professional 2010 does not support designing SharePoint 2010 workflows. The solution is to upgrade to Visio Premium 2010 to get the SharePoint Workflow 2010 templates.


 Subscribe to my post

Worklow activities not supported by SharePoint 2010

For the past few days i’m exploring more into the Worklow Development with SharePoint 2010. I’ve developed applications using Windows Workflow Foundation in the past. Based on that i tried to compare whether the SharePoint workflow framework delivers all the capabilities offered by Windows Workflow foundation. I’ve learnt that the following activities are not supported . 




Invokes a web service from workflow


Invokes another workflow


Stores the definition and execution logic of a RuleSet

Receive Activity

Exposes workflow as WCF service


Used for exposing workflow as web service


Used for exposing worklow as web service


Sends a fault from workflow to web service

Send Activity

Connects to WCF end point


Suspends the execution fo Workflow


Raises exception in workflow


Synchronizes the execution


Groups activities inot a transaction scope


Undo or componesate  work that was previously done


Uses compensation logc


Same purpose as compensate activity

 Even though these activities get listed in Visual Studio Toolbox, they are not suppored in SharePoint Workflows

 Subscribe to my post