Enterprise Keywords management in Office 365 via CSOM


SharePoint 2013 has introduced Microsoft.SharePoint.Client.Taxonomy namespace for metadata management via CSOM. Since Taxonomy API also allows to manage Keywords, i would like to demonstrate how to get/set Enterprise Keywords field values in this post.

Adding Enterprise Keywords column into List

The first example demonstrates how to add Enterprise Keywords column into List:

Setting  Enterprise Keywords field value

The below example demonstrates how to set Enterprise Keywords field value:

Key points:

  • The operation of setting Enterprise Keywords field value consists of two steps, first one to resolve Keyword in Managed Metadata service application (MMS), this what  EnsureKeyword method is intended for.  After Keyword has been retrieved or created if it not existed, the value of Enterprise Keyword field is set (TaxonomyFieldValueCollection type).

DocumentsWithTaxKeyword TermStore_Keywords

Consuming the SharePoint 2013 REST Service from SharePoint Designer

In SharePoint 2013 workflows  was introduced  a new action named Call HTTP Web Service. This action is flexible enough  to make requests to a variety web services including SharePoint REST service.

Figure 1 shows you the Call HTTP Web Service action on the SharePoint Designer 2013 surface.

Call HTTP Web Service Get Operation


Figure 1. SPD Workflow that demonstrates how to leverage Call HTTP Web Service action for Read operation

The specified example demonstrates how to perform Read operation for retrieving webs information:

  1. Create a workflow variable named Url and set it’s value to [%Workflow Context:Current Site URL%]_api/web/webinfos
  2. Insert Build Dictionary action to construct request headers. Add key value pairs  from table 1. Save results into a variable of type Dictionary and named  RequestHeaders
  3. Insert Call HTTP Web Service action. Open Properties window and specify it’s properties as shown in table 2.


Table 1. Request Headers for a RequestHeaders dictionary variable

Name Type Value
 Accept String  application/json;odata=verbose
 Content-Type String  application/json;odata=verbose


Table 2. Call HTTP Web Service action properties for Read operation

Property Name Value
 Address Set value to variable Url that was created in step 1
 RequestType Set value to HTTP GET
 RequestHeaders Set value to dictionary variable RequestHeaders that we’ve constructed to store request header properties in step 2 
 ResponseContent Create a new dictionary variable named Result for storing the response returned by the REST service and set value to variable Result

Scenario: Create Site Workflow

The below example demonstrates how to  perform Create operation using Call HTTP Web Service action, in particular how to create web site from a workflow. 

Note: In order to perform Create/Update/Delete operations using  Call HTTP Web Service action, App permissions for workflow have to be configured.  Please follow the steps in article Create a workflow with elevated permissions by using the SharePoint 2013 Workflow platform to configure App permissions for workflow.


Figure 2 shows you the configured Call HTTP Web Service action for creating web site

Call HTTP Web Service Create Operation

SPD Workflow

Figure 2. SharePoint Designer workflow for creating web site


1.   Create a workflow variable named Url and set it’s value to [%Workflow Context:Current Site URL%]_api/web/webinfos/add

2,3 and 5.   Those steps serve for building payload to submit to the service.  RequestContent parameter of  Call HTTP Web Service action is used for setting payloads to submit to the service.  See tables 4,5 and 6 for a details.

4.   Insert Build Dictionary action to construct request headers. Add key value pairs  from table 1. Save results into a variable of type Dictionary and named  RequestHeaders

6.   Insert Call HTTP Web Service action. Open Properties window and specify it’s properties as shown in table 3.

Table 3. Call HTTP Web Service action properties for Create operation

Property Name Value
 Address Set value to variable Url that was created in step 1
 RequestType Set value to HTTP POST
 RequestHeaders Set value to dictionary variable RequestHeaders that we’ve constructed to store request header properties in step 4 
 RequestContent Set value to dictionary variable RequestContent that was created for storing payload in step 5
 ResponseContent Create a new dictionary variable named Result for storing the response returned by the REST service and set value to variable Result

 Specifying  web site  creation information

For building payload to be submitted to the service the following dictionary variables are initialized in the workflow

Table 4. Metadata dictionary variable

Name Type Value
 type String  SP.WebInfoCreationInformation


Table 5. WebParameters dictionary variable

Name Type Value
 __metadata Dictionary  Variable:Metadata
 Url  String  Parameter:WebTitle
 Title  String  Parameter:WebTitle
 Description  String  Parameter:WebDesc
 Language  Integer  Parameter:Language
 WebTemplate  String  sts
 UseIniquePermissions  Boolean  false


Table 6. RequestContent dictionary variable

Name Type Value
 parameters Dictionary  Variable:WebParameters

For passing information about web site, an Initiation form is used as shown on figure 3


Figure 3. Initiation Form





Introduction to Client Forms Validation in SharePoint 2013

Client side event handlers in SharePoint

In addition to server side Event Model,  SharePoint also provides client side  event handling capabilities when working with List Forms.

Let’s see briefly how it works. In List Forms pages Save button click handler triggers PreSaveItem function , PreSaveItem function is declared in forms.js:

PreSaveAction function from another hand, is a user defined function that allows to override standard behavior for a Save button handler, so in terms of server side event model it is a binding mechanism.

I find this mechanism  pretty convenient for implementing custom client side validation in List Forms,  the following example demonstrates how to implement client side validation for Email field in Contacts list:


Client forms validation in SharePoint 2013

In SharePoint 2013 as part of  Client-Side Rendering (CSR), there is SPClientForms.ClientValidation  namespace (clientforms.js) that contains  types and objects for performing  client side validation in List Forms. For example,

SPClientForms.ClientValidation.RequiredValidator object is intended for evaluating the value of an field control to ensure that the user enters a value (it  is invoked for a fields when SPField.Required property is set to True):

Below is provided a complete example that demonstrates how to implement  client-side validation for Email field in Contacts list:

Key points:

  • CustomClientValidation.EmailValidator object implements a custom validation  for Email field
  • since Email field is a standard Text Field,  the rendering of field control is reused, only custom validator is registered for a field (see function EmailField_Edit for a details)

Working with Discussions List via SharePoint Client Object Model


In this post  will be demonstrated how to perform a common CRUD operations when working with Discussions List via  Client Object Model (JavaScript CSOM) in SharePoint 2010/2013.

Create a Discussion

So, let’s get started with creating a Discussion item. SP.Utilities.Utility.createNewDiscussion method is used for creating a discussion item:

Load all Discussions

Since Discussion Content Type derives from Folder Content Type  we could utilize SP.CamlQuery.createAllFoldersQuery method to construct a query to retrieve all the discussions:

Create a Message

The SP.Utilities.Utility.createNewDiscussionReply method is used to create a Message item (add reply to a discussion item):

Load all Messages

Since message items  are contained within discussion container (Folder) , to identify messages by discussion we will use SPBuiltInFieldId.ParentFolderId field in CAML query:

Import Discussion List

And finally in order to see how to work with Discussions List in action,  let’s discuss one more example.  Suppose we need to import Discussions List content from an external source, let’s say from Stack Exchange. To access Stack Exchange content (Questions and Answers in our case) we will utilize Stack Exchange API:

How to populate a SharePoint List via CSOM


Populating a SharePoint List with data is  required for different purposes quite often. In this article I am going to demonstrate how to populate Contacts list with a fake data using CSOM.

Provision column to a List via SharePoint CSOM

We will utilize Contacts List for demonstration purposes. But before we  proceed, let’s add a Geolocation field to a list.

Since the Geolocation column is not available by default in SharePoint lists, it’s common practice to provision this field to a list programmatically. The code below demonstrates  how to add the Geolocation field  by using the SharePoint client object model:

Generate list data

For populating Contacts list we will utilize Faker.js JavaScript library that is intended for generating massive amounts of fake data, below is provided the complete code:


After running the script the Contacts list will be populated with a fake data as demonstrated below.

Contacts default view


Contacts map view



Some tips and tricks of using SharePoint Client Object Model in PowerShell. Part 1


When it comes to using SharePoint 2010 Client Object Model (CSOM) we need to be ready for certain kind of  limitations  in PowerShell. First of all, it concerns the usage of Generics Methods, for the example ClientRuntimeContext.Load<T> method:

An attempt to call the method ClientRuntimeContext.Load<T> directly will result in the following error PSGenericMethods

This is a limitation of PowerShell  (V1, V2) AFIK. There are several options how to bypass this limitation but in this post I would like to concentrate only on one technique that was originally described in the post Invoking Generic Methods on Non-Generic Classes in PowerShell. The basic idea is to replace the call for ClientRuntimeContext.Load<T> method with the following one:

For invoking a generic methods we utilize MethodInfo.MakeGenericMethod method. Below are demonstrated some examples of usage SharePoint 2010 Client Object Model (CSOM) in PowerShell.

Example: load Web client object

Let’s start with a simple example for loading Web Client Object:

Example: create Wiki page via CSOM

The example below demonstrates how to create wiki page via CSOM.

C# version:

PowerShell version:



In contrary to article Using PowerShell to Get Data from a SharePoint 2010 List that explains how to execute generic methods via inline C#  in PowerShell, this post demonstrates how to utilize Generics Methods in PowerShell natively.


Access and Manipulate Navigation Settings via SharePoint Client Object Model


SharePoint Server OM provides  PortalNavigation class that represents navigation for portal pages and other portal navigation objects. In turn the PublishingWeb class  is used to access the navigation settings (PortalNavigation type).

What about Client Object Model? Unfortunately it is not supported to access and manipulate Navigation settings via CSOM since there is no PublishingWeb Client Object  in SharePoint 2010. But still it possible to accomplish via Client Object Model.

Retrieving Web Client Object with Properties

PortalNavigation class uses internally SPWeb.AllProperties property to store Navigation settings and the same type also exist as a Client Object – Web.AllProperties

ClientObject provides a base class for objects on a remote client, the full list of  client objects available in SharePoint 2010 could be found on MSDN page.

When accessing client objects there are some differences that concern how object properties are initialized. According to the MSDN, in the server object model, when you return an SPWeb object, all of its properties become available for use in code. But to improve performance in the client object model, when you return a Web object (JavaScript: Web) certain properties are not included, and you must explicitly retrieve them.

The following example is aimed to demonstrate how to retrieve Web client object with it properties:

Access and manipulate Navigation settings via CSOM

The following class represents Client Object Model (CSOM) implementation of PortalNavigation class:

The following example  demonstrates how to print and update navigation settings using ClientPortalNavigation class :


Since  Publishing API is not supported in Client Object Model of SharePoint 2010, there is no way to manage  the navigation settings for a publishing site the same way as in Server Object Model. But as was demonstrated in this article it could be accomplished via Web Client Object and Web.AllProperties property.

In turn, in SharePoint 2013 Microsoft.SharePoint.Client.Publishing.Navigation namespace was introduced, in particular WebNavigationSettings class for managing the navigation settings for a publishing site.


Integrating location and map functionality in SharePoint 2010


In SharePoint 2013 was  introduced a new field type named Geolocation that enables you to annotate SharePoint lists with location information. For example, you can now make lists “location-aware” and display latitude and longitude coordinates through Bing Maps. An entry is typically seen as a pushpin on a map view.

Due to the lack of these capabilities in SharePoint 2010 it was decided to fill the gap and bring location and map functionality into SharePoint 2010 and this is one the main reason why this project was initiated.

So, the aim of this project is to bring  location and map functionality into SharePoint 2010  (and more) the same way as they are currently available in SharePoint 2013.

Geolocation field

Geolocation field overview

SharePoint 2013 introduces a new field type named Geolocation that enables you to annotate SharePoint lists with location information.  The custom Geolocation field have been created as part of this project  that is intended for the same purposes in SharePoint 2010.

In columns of type Geolocation, you can enter location information as a pair of latitude and longitude coordinates in decimal degrees.

Add Geolocation column to a list

Geolocation column could be added to a list using standard capabilities of SharePoint 2010 UI as shown in Figure 1.

Figure 1. Add Geolocation column


After the Geolocation column has been added, it could be used as shown below

Figure 2 New or Edit Form with Geolocation column

Figure 3. Display form with Geolocation column for Contacts list


Figure 4. Representing Geolocation column in a list view


Map view

Map View Overview

A map view is a SharePoint view that displays a map (with data obtained from the  Maps service ), using longitude and latitude entries from the Geolocation field type. When the Geolocation field type is available on the SharePoint list, a map view can be created  from the SharePoint UI. In the list, SharePoint 2010 displays the location on a map powered by Maps service, currently Bing Maps is supported only.

Create a map view

The following steps demonstrate how to create a map view from the SharePoint 2010 UI.

  1. Open the SharePoint 2010 list with Geolocation column.
  2. Choose Create view in Ribbon menu
  3. On the Choose a view type page, choose Map View, as shown in Figure 5.
    Figure 5. Choosing a view type
  4. Save a view. A map view is created, as shown in Figure 6.
    Figure 6. Completed map view


SharePoint 2010 Maps project is hosted on GitHub.

How to to retrieve and display Social Ratings in Content Query web part


In this post we will continue the discussion of accessing Social Data in Content Query web part that we started in the previous post. But this time we are going to customize Content Query web part in order to retrieve and display Social Ratings.  Our goal here to retrieve and display social ratings using the same way that they are being displayed  in List View.

When Ratings is enabled in List settings, the rating field is rendered in List View as shown below


and the customized Content Query web part for displaying Ratings control  will look like this




So, lets start with the implementation of XSL stylesheet for rendering the Ratings control.

Social Ratings fields in SharePoint 2010

SharePoint 2010 comes with the following fields for Social Ratings:

  • AverageRating
  • RatingCount

For rendering AverageRating field in List View the  TEMPLATE\LAYOUTS\XSL\fldtypes_ratings.xsl is used. We will utilize templates from this file, but in order to make it work properly with CQWP, some modifications should be applied.

Ratings XSL stylesheet for CQWP

Templates definitions for the client side initialization and for rendering of of Ratings manager

Main XSL stylesheet

Custom ContentQueryMain.xsl is used, in which  the template for client side initialization of Ratings control is invoked


Item XSL stylesheet

Custom ItemStyle.xsl is used, in which  the template for rendering Ratings control per page is invoked


Ratings XSL Parameters

Parameter values are retrieved from resource file  and are passed via ParamaterBindings web part property

Let’s summarize.

In order to configure CQWP  for displaying Social Ratings , the following steps should be accomplished:


Customize the rendering of a List View in Sharepoint 2013: Displaying List Items in Accordion


We have already discussed how to create Accordion List View in SharePoint 2010 in this post.
SharePoint 2013 introduces client side rendering framework for List View that allows to define the rendering logic of SharePoint list views using HTML/JavaScript. So, let’s discuss how to create Accordion List View in SharePoint 2013 based on client-side rendering.

For demonstration purposes we will create FAQ List based on Custom List. Default view for our list  will look like this


And our goal here to customize it in such a way list items will be displayed  in accordion as shown below



In order to simplify our solution we restrict ourselves to the creation of client side rendering template only and applying it to the existing List View. If you are interested how to build custom solution for Accordion List  please follow my post about creating Accordion List View for SharePoint 2010.

Create Custom List for FAQ

FAQ List is based on Custom List. For storing questions we will utilize Title field, for Answers we will create new field with Note type

Create  client-side rendered view for Accordion

Client-side rendered view of an FAQ list is presented below

Customize a List View

The last step is to apply client-side rendering template to existing view. Let’s first add FAQ List instance on on page, after that  we only need to specify JSLink property value for List View

Please note that actually  three JavaScript files have been specified(the first two are jQuery libraries) for  JSLink property. All of them are stored in my case in hive, but of course they could be stored not only in file system.