2

I am trying to create with search(display templates). To return a list with only the followers. The following error is throwing when running:

"Error: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."

I just can't find where i make a mistake cause i think i declare all in the right scope

// 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();

if (!$isEmptyString(uPicUrl)) {
    uPicUrl = uPicUrl.replace("MThumb", "LThumb");
} else {
    uPicUrl = placeholder;
}
if ($isEmptyString(uname)) {
    uname = ctx.CurrentItem.YomiDisplayName
}

clientContext.load(peopleFollowingMe);
var personlist = [];

function followersResult() {
    var followers = 0;
    var results = peopleFollowingMe.getEnumerator();
    while (results.moveNext()) {
        var person = results.get_current();
        personlist.push(person.get_displayName());
        followers++;
    }
    $("#followersCount").text('(' + followers + ')');
}

// Failure callback.
function requestFailed(sender, args) {

}

clientContext.executeQueryAsync(followersResult, requestFailed)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.