Is there a way to retrieve the currently logged in user's colleagues' usernames?
I found this which shows how to do it using server object model, but haven't found anything for JavaScript object model.
Is there a way to retrieve the currently logged in user's colleagues' usernames?
I found this which shows how to do it using server object model, but haven't found anything for JavaScript object model.
I might be wrong, but isnt Colleagues the same as SPS-Peers? If so you could get it with UserProfiles.
Example:
function getPeers() {
var context = SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(context);
userProfileProperties = peopleManager.getMyProperties();
context.load(userProfileProperties, 'Peers');
context.executeQueryAsync(success, fail);
}
function success(){
var peers = userProfileProperties.get_peers();
console && console.dir(peers);
}
function fail(sender, args) {
console && console.log("Error");
}
SP.SOD.loadMultiple(['sp.js', 'userprofile'],function() {
getPeers();
});
Unfortunately it does not seem possible to archive via SharePoint CSOM/JSOM API since SSOM ColleagueManager class is not supported in CSOM/JSOM API.
But you could utilize SharePoint Web Services, in particular UserProfileService.GetUserColleagues method for that purpose:
SPServices example:
$().SPServices({
operation: "GetUserColleagues",
AccountName: $().SPServices.SPGetCurrentUser({fieldName: "Name"}),
completefunc:function(data,status) {
//process GetUserColleaguesResult...
}
});