Sharepoint notes : Sharepoint 2013 in maintenance mode

November 16, 2015

Issue : “We apologize for any inconvenience, but we’ve made the site read only while we’re making some improvements.”

So I woke up this morning finding one of our SharePoint 2013 sites in read-only mode. When I browsed the site I got the following message: “We apologize for any inconvenience, but we’ve made the site read only while we’re making some improvements.”


On further investigation I noticed that the nightly backup of this specific site collection did not complete successfully”. When you backup a Site, SharePoint places the site in read-only mode. But since my backup hanged the site never got out the read-only mode.

When you check the site in the Site Collection Quota and Locks Screen you’ll find all options greyed out:


I checked the SPSite.MaintenanceMode setting and it was set to true.


So I first turned to PowerShelll trying to set the lockstate to unlocked. And although I did not get an error, the site was still locked. So I tried good old STSADM. Operation completed successfully but still LOCKED.



Luckily since the April 2013 CU update for SharePoint 2013 we now have the SpsiteAdministration.ClearMaintenanceMode method. So we can clear the flag with the flowing two lines:

$site = new-object Microsoft.SharePoint.Administration.SPSiteAdministration(‘http://intranet.demo.local’)


and your site is out of maintance mode again!


Sharepoint notes : Invalid characters in filenames

October 30, 2015

As per share point, the below are invalid character in a file name which we are already handing from UI.
” # % & * : ? \ / { | } ~

the below things about share point file names which we have to implement across all the processes.

• Do not use: ” # % & * : ? \ / { | } ~
• File names cannot be longer than 128 characters
• Do not use the period character consecutively in the middle of a file name.
• You cannot use the period character at the end of a file name
• You cannot start a file name with the period character
• Many other symbols are not recommended such as $^()-_=+[]`! (other international currency symbols and international symbols should be avoided in site names, but some are more acceptable in file names. Ascii is preferred when possible.

Calling Sharepoint 2013 methods as services using WCF

September 12, 2014

webservice can transfer dataset but not generic lists
where as wcf can transfer both dataset and lists

sp object model cant be accessed in normal appln.sp context will come only if appln is hosted in sp like gmc ,ecg applns.

for accessing sp object model in web appln u have to expose those sp methods as webservices in sp machine and consume them in the web appln.

host webservice in sharepoint and consuming (2007 sharepoint.using disco command)

sharepoint service network credentials authentication

how to add a new item to sharepoint list programmatically

addding files to doc library
document library

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

host wcf service in sharepoint and consuming : (select sharpoint 2010 empty project sharepoint template.add service reference and not web reference)
authentication : anonymous enabled
error :The HTTP request is unauthorized with client authentication scheme ‘Negotiate’. The authentication header received from the server was ‘NTLM’.

wcf specified column is added
Failed to convert key to token – The public key for assembly ‘(null)’ was invalid when running the sn command to know the publickeytoken of an asembly

ERROR: When trying to know the Public key token fo the strong assembly using sn command you may receive an error as below:
Failed to convert key to token — The public key for assembly ‘(null)’ was inval id.

SOLUTION: This error comes because the command options are case sensitive. The option Tp is case sensitive.
C:\Program Files\Microsoft Visual Studio 9.0\VC>sn -Tp \PendingTaskReport.dll

Error : Service Reference Error: Failed to generate code for the service reference
soln: Have to uncheck the Reuse types in all referenced assemblies from Configure service reference option

An unhandled exception of type ‘System.TimeoutException’ occurred in mscorlib.dll

Additional information: The request channel timed out while waiting for a reply after 00:00:59.8750656. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.


if u have people as column in document library or list then u have to insert value there like below (use elevateprivileges)
How to Insert?

Let us suppose, you need to add more than one user at single time in SharePoint List. Users’ values may come from an Active Directory or metadata. All the users are in a string as comma or semicolon separated value. Let us suppose users are in below format.

string usercontrolvalue = “dhananjay,arun,anoj,patra,mub”;

We need to inert these multiple users in a column of type People or Group in SharePoint list.

Step 1

First we need to split name of all the users from the string. Since in our case users are comma separated so below code will make a string array with users as value at different index.

string[] userarray = usercontrolvalue.Split(‘,’);

Step 2

Now we need to convert users as string to SPFieldUserValue. Below function is taking user name as string and converting that into SPFieldUserValue.

_Web variable is denoting current web where List is part of.

public SPFieldUserValue ConvertLoginName(string userid)
SPUser requireduser = _web.EnsureUser(userid);
SPFieldUserValue uservalue = new SPFieldUserValue(_web, requireduser.ID, requireduser.LoginName);
return uservalue;

Step 3

We need to make instance of SPFieldUserValueCollection

SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();

Step 4

For all the user; we need to convert that as SPFieldUserValue then add that them to SPFieldUserValueCollection instance

for (int i = 0; i < userarray.Length; i++)
SPFieldUserValue usertoadd = ConvertLoginName(userarray[i]);

Only we need to perform above said task. For your reference entire code as below,

Entire code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
namespace TestingMultipleUsre
public partial class _Default : System.Web.UI.Page
SPWeb _web;
SPSite _site;
SPList myList
protected void Page_Load(object sender, EventArgs e)
string usercontrolvalue = "dhananjay,arun,anoj,patra,mub";
_site = new SPSite("http://adfsaccount:2222/&quot;);
_web = _site.OpenWeb();
myList = _web.Lists["TestingUser"];
_web.AllowUnsafeUpdates = true ;
myList = _web.Lists["TestingUser"];
SPListItem item = myList.Items.Add();
SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();
string[] userarray = usercontrolvalue.Split(',');
for (int i = 0; i cd c:\windows\syswow64\inetsrv

c:\Windows\SysWOW64\inetsrv>appcmd.exe list config -section:system.webServer/ser

c:\Windows\SysWOW64\inetsrv>appcmd.exe set config -section:system.webServer/serv
erRuntime /uploadReadAheadSize:”204800″
Applied configuration changes to section “system.webServer/serverRuntime” for “M

in vs command prompt :
at the solution/bin/debug folder type : sn -T “dllname” (for getting strong name) …u will get publickeytoken of that assembly
at the solution/bin/debug foder type : gacutil -i “dllname”(for keeping into gac)
at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI type disco http://skeltadtptest:1111/_vti_bin/final/service.asmx.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

How To: Add Time/Date to Layouts or Master Page

May 9, 2012

Source :

To add this JavaScript to your page layout do the following:

  1. Add in the following code anywhere within your page layout:
    <table cellpadding=”0″ cellspacing=”0″>
            <td valign=”top”>
                <script type=”text/javascript”>
                    function getClockTime()
                        var now    = new Date();
                        var hour   = now.getHours();
                        var minute = now.getMinutes();
                        var second = now.getSeconds();
                        var ap = “<span class=’company-homepagetime-ampm’>AM</span>”;
                        if (hour   > 11) { ap = “<span class=’company-homepagetime-ampm’>PM</span>”;}
                        if (hour   > 12) { hour = hour – 12;      }
                        if (hour   == 0) { hour = 12;             }
                        if (minute < 10) { minute = “0” + minute; }
                        if (second < 10) { second = “0” + second; }
                        var timeString = hour +
                            ‘:’ +
                            minute +
                            ” ” +
                        return timeString;
                    } // function getClockTime()
                        var clockTime = getClockTime();
            <td valign=”top”>
                <script type=”text/javascript”>
                    var months=new Array(13);
                    var day=new Date();
                    var lmonth=months[day.getMonth() + 1];
                    var date=day.getDate();
                    var year = day.getFullYear();
                    document.write(lmonth + ” ” + date + “, ” + year);
  2. Then Add in the following CSS to give it a little style
        color: #000;
        font-family: Arial, sans-serif;
        font-weight: normal;
        font-size: 30px;
        text-align: left;
        padding: 10px 0px 0px 15px;
        color: #000;
        font-family: Arial, sans-serif;
        font-weight: normal;
        font-size: 20px;
        text-align: left;
        color: #000;
        font-family: Arial, sans-serif;
        font-size: 14px;
        text-align: left;
        padding: 0px 0px 0px 17px;

The result should look similar to the following:

Sharepoint Notes : Content Types – Featurs

December 24, 2011



What is a content type?
In the course of a single project, a business might produce several different kinds of content, for example, proposals, legal contracts, statements of work, and product design specifications. Although these documents might be stored together because they are related to a single project, they can be created, used, shared, and retained in different ways. A business might want to collect and maintain different kinds of metadata about each kind of content.

Windows SharePoint Services 3.0 enables organizations to define these different sets of documents as content types. A content type is a group of reusable settings that describe the shared behaviors for a specific type of content. Content types can be defined for any item type in Windows SharePoint Services 3.0, including documents, list items, or folders. Each content type can specify:

The columns (metadata) that you want to assign to items of this type.
The document template on which to base new items of this type (document content types only).
The custom New, Edit, and Display forms to use with this content type.
The workflows that are available for items of this content type.
The custom solutions or features that are associated with items of this content type.
Content types provide organizations with a way to manage and organize content consistently across different lists and libraries in a site collection (site collection: A set of Web sites on a virtual server that have the same owner and share administration settings. Each site collection contains a top-level Web site and can contain one or more subsites.), and they also make it possible for a single list or library to contain multiple item types or document types.




A content type is a reusable collection of metadata (columns), workflow, behavior, and other settings for a category of items or documents in a Microsoft SharePoint Foundation 2010 list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.

For example, imagine a business situation in which you have three different types of documents: expense reports, purchase orders, and invoices. All three types of documents have some characteristics in common; for one thing, they are all financial documents and contain data with values in currency. Yet each type of document has its own data requirements, its own document template, and its own workflow. One solution to this business problem is to create four content types. The first content type, Financial Document, could encapsulate data requirements that are common to all financial documents in the organization. The remaining three, Expense Report, Purchase Order, and Invoice, could inherit common elements from Financial Document. In addition, they could define characteristics that are unique to each type, such as a particular set of metadata, a document template to be used in creating a new item, and a specific workflow for processing an item.

Content Type Scope

The Microsoft SharePoint Foundation site in which you create a content type determines its scope—that is, the extent of its availability. A site content type becomes available to lists and document libraries within the site on which the content type is created, and also to lists and document libraries in any child site.

Content Type Features

Content types are a site-scoped Feature. Features are a way of encapsulating SharePoint Foundation functionality for ease of distribution and deployment. Features provide a mechanism by which you can package the files that a solution needs, such as content types, Web Parts, lists, and site definitions. You can package the necessary files into a .wsp file, which is basically a .cab file that contains a manifest that lists its contents.

Inside the Feature, the feature.xml file contains references to all the element manifests within that Feature. Content type definitions are element manifests. You must create a content type definition for each content type that is included in your Feature.


Sharepoint 2010 workflows

December 24, 2011

types of workflows:


2.Content Type (Reusable )

3. Sites

Out of box workflows:


2.Collect feedback

3.Collect signature

4. Three state

5. Disposition

6,Translation Mngt

Defining sharepoint custom sequential workflow thru code:


When to go for Visual Studio workflows in place of sharepoint designers:


When should I use Visual Studio for Workflow?

As I mentioned earlier SharePoint Designer (SPD) is a great platform for developing basic workflows, however it has several limitations and in some cases these can mean that you have to look at Visual Studio as the solution for your workflow design.

In my experience the limitations of SPD are as follows:

  1. Workflows are bound to a specific list/site
     In SPD any workflow you create can only exist on the list (and in the site) that you created the workflow on.  You cannot design a workflow and then move it to another site.
  2. No code support
    You cannot write custom code within the SPD workflow tools.  You can write custom activities to include in SPD, but you would need to do that in Visual Studio anyway.
  3. No WSS Solution Package (WSP) support
    Your workflow will be deployed to the site via SPD and there is no support for packaging these as WSP files, which provide a more maintainable and upgradeable method of deploying customisations to SharePoint.
  4. No support for State Machine workflows
    You can only build Sequential workflows with SPD, there is no support for State Machine Workflows.


December 24, 2011

DependencyProperty :

If you use Sharepoint Designer to build workflows, sometimes you will feel the need of some extra actions in the designer (see below).Well Microsoft has provided with a class to do that, this class is call it DependencyProperty. MSDN defines the DependencyProperty like this: Represents a property that can be set through methods such as, styling, data binding, animation, and inheritance.


How does Sharepoint works?

The browser sends a DAV packet to IIS asking to perform a document check in. PKMDASL.DLL, an ISAPI DLL, parses the packet and sees that it has the proprietary INVOKE command. Because of the existence of this command, the packet is passed off to msdmserv.exe, who in turn processes the packet and uses EXOLEDB to access the WSS, perform the operation and send the results back to the user in the form of XML