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

Get the people who are following the current user.

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

SP.UserProfiles.PeopleManager.getMyFollowers()

Return value

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

Remarks

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

Example

The following example shows how to use the getMyFollowers 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 peopleFollowingMe;

// Send the request to get followers.
function getPeopleFollowingCurrentUser() {

    // 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 following the current user.
    peopleFollowingMe = peopleManager.getMyFollowers();
    clientContext.load(peopleFollowingMe);

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

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

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

See also

Other resources

PeopleManager

Follow people in SharePoint 2013