getPeopleFollowedByMe Method

SP.UserProfiles.PeopleManager.getPeopleFollowedByMe Method (sp.userprofiles)

SharePoint 2013

Gets the people who the current user is following.

Last modified: June 25, 2013

Applies to: apps for SharePoint | Office 365 | SharePoint Foundation 2013 | SharePoint Server 2013

SP.UserProfiles.PeopleManager.getPeopleFollowedByMe()

SP.ClientObjectList
The people who the current user is following, as a list of PersonProperties objects.

The recommended API to use for this task is SocialFollowingManager.getFollowed.

The following example shows how to use the getPeopleFollowedByMe method and how to iterate through the returned list of PersonProperties objects and get the Display Name property of each person.

For information about how to set up a project to run this code, see How to: Follow people by using the JavaScript object model in SharePoint 2013.

var peopleFollowedByMe;

// Send the request to get followed people.
function getPeopleFollowedByCurrentUser() {

    // Get the current client context.
    var clientContext = SP.ClientContext.get_current();

    // Get the PeopleManager instance.
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    // Get the people who are followed by the target user.
    peopleFollowedByMe = peopleManager.getPeopleFollowedByMe();
    clientContext.load(peopleFollowedByMe);

    // Send the request to the server.
    clientContext.executeQueryAsync(iterateThroughResults, requestFailed)
}

// Get information from the returned list.
function iterateThroughResults() {
    var results = peopleFollowedByMe.getEnumerator();
    while (results.moveNext()) {
        var person = results.get_current();
        alert('The user is following ' + person.get_displayName());
    }
}

// Failure callback.
function requestFailed(sender, args) {
    alert('Error: ' + args.get_message());
}
Show:
© 2016 Microsoft