SocialCommentManager.GetComments(uri) not fetching all the comments


  • I want to fetch all the comments of a particular list item, but I am getting only the comments entered by System Account (and not of other users).

    Ex: If I have 2 comments from System Account and 2 comments from other users, then the following code is only displaying the 2 comments from System Account.

    SocialCommentManager socialCommentManager = new SocialCommentManager();
    SocialComment[] comments = socialCommentManager.GetComments(item.Web.Url + item.ParentList.DefaultDisplayFormUrl + item.ID);

    foreach (SocialComment comment in comments)

    How can I resolve this issue to get all the comments of a particular url.

    Wednesday, November 13, 2013 12:33 PM


  • Hi,                                                             

    From this documentation(MSDN), "The overloaded GetComments method retrieves all SocialComment objects for a specified URL or user. If you specify a URL, the method returns all social comments added to that URL by the current user in the current SPServerContext. If you specify a user, the method returns all social comments that the specified user added".

    If you want to retrieve all the comments of a specific URL, you can use SocialCommentManager.GetComments Method (UserProfile, Uri) which can Retrieves all of the social comments created by the specified user for the specified URL.

    Another solution is to impersonate the SPSite object with an account who has the rights to manage social data.

    We can give the permission in Central Administration –> Application Management –> Service Applications –> User Profile Service, then add an account to the Administrators group. Then use a code like this to get all the comments of the URL:

    public int GetNumberOfNewsPageComments
            (SPSite currentSite, string pageUrl, int max)
        var serviceContext = 
        var socialCommentManager = 
                new SocialCommentManager(serviceContext);
        var comments = socialCommentManager
                .GetComments(new Uri(pageUrl), max);            
        if (comments != null)
            return comments.Length;
        return -1;


    Best regards

    Patrick Liang
    TechNet Community Support

    Thursday, November 14, 2013 10:27 AM