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

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.