How to get User Information List information using JSOM in SharePoint 2013/2016/online?

Hello SharePointers,

Below is the sharepoint JSOM code to user information list information for a logged in user.

ExecuteOrDelayUntilScriptLoaded(getUserProfile, “sp.js”);
function getUserProfileInformation(){
var userID= _spPageContextInfo.userId;
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var userInfoList = web.get_siteUserInfoList();
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(“” + userID + “1”);
this.collListItem = userInfoList.getItems(camlQuery);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args){
var item = collListItem.itemAt(0);
var MyuserName = item.get_fieldValues().UserName;
var MydisplayName= item.get_fieldValues().Title;
var Myemail= item.get_fieldValues().EMail;
var html=””;
if(MyuserName !=null){
html+=”<img src=’/_layouts/15/userphoto.aspx?size=S&username=” + MyuserName + “‘/>”;

Name:”+ MydisplayName+”


Email: “+ Myemail+”

var profileDiv = document.getElementById(“CurrentUserProfile”);
profileDiv.innerHTML = html;
function onQueryFailed(sender, args) {
//alert(‘Request failed. ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());
<div id=”CurrentUserProfile”>

Happy Sharepointing đŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *