In this post, let me explain you about getting the count of sites followed by the user in SharePoint 2013. First Open Visual Studio in your system. Select Console Applciation template and give as name “GetallList”, Add a Microsoft.Cleint Assembly refrence file in right side refrence tab in visual studio. And then Replace Program.cs with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.SharePoint.Client; namespace GetallList { class Program { static void Main(string[] args) { // ClientContext - Get the context for the SharePoint Site ClientContext clientContext = new ClientContext("http://gauti.sharepoint.com/sites/SP"); //Pass the credentials for whom we need to get the count of followed documents // By default It will take current user who runs this application - Here it will take Administrator because the application is running with that account clientContext.Credentials = new NetworkCredential("Gowtham", "paswword5", "SP2013"); // Get the SocialFollowingManager instance // Provides methods for managing a user's list of followed actors (users,documents, sites, and tags) SocialFollowingManager followingManager = new SocialFollowingManager(clientContext); // Get the count of followed documents ClientResult < int > followingCount = followingManager.GetFollowedCount(SocialActorTypes.Sites); // Execute the query to the server clientContext.ExecuteQuery(); // Display the count of followed documents Console.WriteLine("Count of followed documents: " + followingCount.Value); Console.ReadLine(); } } } |
After that, press F5 button and check the output.
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options.