Skip to content Skip to sidebar Skip to footer

Sharepoint 2013 Online - Display Currentuser Information In Page

I need to get the currentUser information, like email address and or name when a Home.aspx page is loaded in a specific area on the page like maybe the footer area. I have search a

Solution 1:

Most probably init method is not executed since SP.SOD.executeOrDelayUntilScriptLoaded method expects SharePoint Client Library sp.js to be loaded first. Use SP.SOD.executeFunc method instead since it supports on demand scripts.

SP.SOD.executeFunc('sp.js', 'SP.ClientContext',function(){  
  var context = new SP.ClientContext.get_current();
  var web = context.get_web();
  var currentUser = web.get_currentUser();
  context.load(currentUser);
  context.executeQueryAsync(
  function(){
      console.log(currentUser.get_loginName()); 
  }, 
  function(sender, args){
      console.log('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
  });
});

Post a Comment for "Sharepoint 2013 Online - Display Currentuser Information In Page"