Page 1 of 1

Current User Display Name

Posted: 10 Aug 2016
by Stu
How do you get the current users Display name?

Thanks

Stuart

Re: Current User Display Name

Posted: 11 Aug 2016
by Dmitry Kozlov
Hi Stu,

Please, use the code:

Code: Select all

SP.SOD.executeOrDelayUntilScriptLoaded((function () { 
    var ctx = new SP.ClientContext.get_current(); 
    var web = ctx.get_web(); 
    ctx.load(web); 
    var user = web.get_currentUser(); 
    user.retrieve(); 
    ctx.executeQueryAsync( 
    function () { 
      alert(user.get_title());
    }); 
}), "SP.js"); 

Re: Current User Display Name

Posted: 11 Aug 2016
by Stu
Thanks it worked perfectly