Sunday, 10 February 2013

Programmatically Create Social Profile in SharePoint 2013

Its been a while since I wrote a blog entry. Here is something that will be useful to all.

In User Profiles each user now has a Social Profile to track interact with Social activities or properties of a User. In addition to the existing ones in SharePoint 2013 Ms has Included the following new objects that represent Users and User Properties:

The SocialActor object represents users (and other entities) for feed,following and other social activities.

The PersonProperties object contains general user properties and user profile properties. PersonProperties is the primary API for accessing user properties from client-side code.

//Create a Social Profile with SPSocialFollowingManager

SPSocialFollowingManager _followManager = new SPSocialFollowingManager(profile);

//Create a Social actor of type Document

SPSocialActorInfo newActor = new SPSocialActorInfo();

newActor.ActorType = SPSocialActorType.Document;

//Follow the document actor
newActor.ContentUri = new Uri('path of document to follow');

Please Note that to Create or Change user profiles, you must use the server object model. User profiles and user profile properties from client APIs are read-only (except the user profile picture).

Ads by Google

No comments:

Post a Comment