0

How do I go about getting the client username with the javascript client object model? I can't find anything helpful in microsoft's documentation, it's awful :|

user1472511
  • 201
  • 3
  • 4
  • 1
    Duplicate of http://sharepoint.stackexchange.com/questions/20802/get-the-user-id-via-javascript ? – eirikb Sep 14 '12 at 13:03

1 Answers1

2
var ctx = new SP.ClientContext();
var user = ctx.get_web().get_currentUser();
ctx.load(user);
ctx.executeQueryAsync(function() {
    console.log(user);
});​
eirikb
  • 7,405
  • 5
  • 35
  • 67
  • Slightly different approach than what @vedran-rasol did in http://sharepoint.stackexchange.com/questions/20802/get-the-user-id-via-javascript – eirikb Sep 14 '12 at 13:07