SharePoint 2013 Work Management Service: Part 1 (Introduction to Client API)

The Work Management Service application was one of the new service applications introduced in SharePoint 2013. This service provides functionality to aggregate tasks from several locations into a central location in SharePoint. With the Work Management Service, we can aggregate tasks from SharePoint sites, an Exchange Server and Project Server into the user's My Site so that the user can see all the tasks assigned in one place. It also provides an API for developers to write custom components.
 
Consider you are working on an Intranet portal site. This service can be very helpful to write a component that sits on the home page of the portal site and displays all the tasks assigned to the logged in user.
 
Note

We cannot use the Work Management Service API from a SharePoint APPS (at least now, as I am writing this article). I tried to use it in a provider hosted app but got an error that specified the Work Management Service assembly does not support app authentication.
 
Let us start by setting up all the required things for the Work Management Service.
 
From Central Administration select Application Management -> Manage Service Application then create a new "Work Management Service Application".
 
 
 
Make sure that the "Work Management Service" is started.
 
 
I have created two site collections with Test data.
 
 
 
The following are task lists in the two sites respectively.
 
 
 
 Now navigate to your Profile page (Person.aspx) by clicking "OneDrive" of your SharePoint site and you will see a "Tasks" link in the left navigation.
 
 
Alternatively, navigate to the following URL: "/personal/USERID/AllTasks.aspx". In the tasks list, you'll see the combined list of tasks from both the SharePoint sites we created for testing.
 
 
Working with the API
 
We will the use of the client API of the Work Management Service to retrieve information related to our tasks. In work management terminology, "LOCATIONS" are the places where the tasks are stored. Let us try to retrieve the locations using the client-side object model. For demo purposes, I am writing the code in a console application.
 
Make sure you have all the DLL references in place.
 
 
The WorkManagement client DLL can be found in the "15/ISAPI" folder.Then we create a ClientContext and an instance of UserSettingsManager to retrieve the locations information.
 


Output
 
We will work more with the Work management Client-side API in the following series.
 
Cheers