Skip to content

Instantly share code, notes, and snippets.

@maxali
Created January 27, 2016 00:49
Show Gist options
  • Save maxali/81ee7f6e317532e084eb to your computer and use it in GitHub Desktop.
Save maxali/81ee7f6e317532e084eb to your computer and use it in GitHub Desktop.
function getUserInformationList() {
var context = SP.ClientContext.get_current();
var list = context.get_web().get_siteUserInfoList(); //.get_currentUser();
var userInfoItems = list.getItems(SP.CamlQuery.createAllItemsQuery());
context.load(userInfoItems);
context.executeQueryAsync(
// success callback
function () {
//var listItemInfo = '';
//listItemInfo = "<table border=1><tr><td>Picture</td><td>Title</td><td>Name</td><td>Email</td><td>MobilePhone</td><td>WebSite</td><td>UserName</td></tr>";
//for (var i = 0; i < userInfoItems.get_count() ; i++) {
// var item = userInfoItems.itemAt(i);
// var picture = (!!item.get_fieldValues()["Picture"]) ? item.get_fieldValues()["Picture"]["$1_1"] : "";
// listItemInfo += "<tr><td><img src='https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=" + item.get_item("EMail") + "&size=HR64x64' /></td>"
// listItemInfo += "<td>" + item.get_item("Title") + "</td>";
// listItemInfo += "<td>" + item.get_item("Name") + "</td>";
// listItemInfo += "<td>" + item.get_item("EMail") + "</td>";
// listItemInfo += "<td>" + item.get_item("MobilePhone") + "</td>";
// listItemInfo += "<td>" + item.get_item("WebSite") + "</td>";
// listItemInfo += "<td>" + item.get_item("UserName") + "</td>";
//}
//listItemInfo += "</tr></table>";
//$('#message').html(listItemInfo);
return item.get_fieldValues()
//fail callback
}, function onGetUserFail(sender, args) {
alert('Failed to get user name. Error:' + args.get_message());
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment