TechBubbles Microsoft Technology BLOG

Social Features in SharePoint 2013 Part2

A Big boost for social features in SharePoint 2013 which were an extension for the features introduced in SharePoint 2010. In SharePoint 2013 Collaborating and exchanging information options have been improved a lot, Features like Micro Blogging, Community sites and sharing introduced in SharePoint 2013. The out of the box SharePoint 2013 social features can be read here and this post outlines the different ways to interact with social data API in SharePoint 2013. The new Social namespace contains API for interacting with feeds, posts and people.

Microsoft.SharePoint.Client.Social namespace can be used in .NET Client Object model, SP.Social in JavaScript object model and Microsoft.Office.Server.Social namespace in Server Object Model for working with the Social Data.

Retrieving the Social Feed for all users

Getfeed Method in SocialFeedManager class allows you to retrieve Social Feed for all users

image

Getfeed method returns the results as collection of threads, Iterating over the retrieved feed can be performed using the below code

image

The possible values for SocialFeedType enum and SocialThreadAttributes are shown below

image

You can call GetAlllikers method on FeedManager class to retrieve all liker information on particular post

image

Creating and publishing the posts to Social feed data as follows

image

Different dataitem types that you can include in a post are

image

Mentioning someone in post

Define the mention that you want to include in the post using SocialDataItem class as below

image

Adding the defined mention to post

Create a post and put a place holder for including mention and add the mention to post content items using the below code snippet

image

Publishing a post with tag

Including a tag in a post is similar to mentioning someone in the post, You have to create the tag first using SocialDataItem class and then specify the SocialDataItemType

image

Adding the tag to a new post requires place holder, if the tag is new then it adds to the server tag collection

image

Following people, sites and posts is an another important feature in SharePoint 2013 Social Features. When you follow a document or person then your activity shown up in the news feed which is a mysite feature in SharePoint 2013.

Following people in SharePoint 2013

In order to follow people in SharePoint 2013, Create an instance to SocialFollowingManager and pass the client context value as parameter and then define the Social Actor information that you want to follow

image

Check whether you are already following the target user and if not then call follow method on FollowingManager class

image

If you want to stop following a particular user then you can write the below code

image

Getting the list of people who are following you by creating an instance to the SocialFollowingManager class and then call the method GetFollowers as shown below

image

To display the list of people who the current user is following, call the GetFollowed method on SocialFollowingManager class.

Getting User Profile Property values

User Profile property information is about SharePoint user which includes display name, E-mail address, title and other personal information. Using Client-Object model you can only read the user profile but can not update. To update the user profile properties then you have to use server object model methods.

Create an instance to PeopleManager class and pass the clientcontext as a parameter then call the GetPropertiesFor method on it.

image

You can iterate over result and can display each user profile property values as below

image

Conclusion

This post explained different ways to interact with SharePoint 2013 social data using Client Object Model. The important features like retrieving the feed content, creating a post , mentioning and tagging, following people and retrieving the user profile properties explained with examples. The above code snippets can be used to customize the out of the box social data features in SharePoint 2013.

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

1 Comment

  • I want to create post with multiple mention users…so how i can do that…plz help me out…..

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud