0

Hi I need to get display name like "John Lous" but this display the domain name like "USA\Lousjohn" I am using this code.

ctx = new SP.ClientContext.get_current();
currUser = ctx.get_web().get_currentUser(); 

Is the above code correct. What I have to do to display the display name.

  • Kindly research in detailed manner before posting questions... – Ankitkumar Malde Feb 16 '16 at 11:49
  • Yes Ankit, I have researched very detailed and then only asked it. – Bagavathi Feb 16 '16 at 13:52
3

Please try following Code :

    function getCurrentLoggedUser(){
        var context = new SP.ClientContext.get_current();
        var web = context.get_web();
        this.currentUser = web.get_currentUser();
        context.load(currentUser);          
        context.executeQueryAsync(getCurrentLoggedUserSuccess, getCurrentLoggedUserFailed);    
    }  
    function getCurrentLoggedUserSuccess(){
        var currentLoggedUserName = currentUser.get_title();
    }
    function getCurrentLoggedUserFailed(sender, args){
      //failure callback
    }
| improve this answer | |
0

You can use the below code to get user details

var context = new SP.ClientContext.get_current();
this.website = context.get_web();
this.currentUser = website.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args)
{
console.log(currentUser.get_loginName());
console.log(currentUser.get_id());
console.log(currentUser.get_title());
console.log(currentUser.get_email());
}
function onQueryFailed(sender, args)
{
alert('request failed ' + args.get_message() + '\n'+ args.get_stackTrace());
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.