36
rated 0 times
[
41]
[
5]
/ answers: 1 / hits: 23034
/ 14 Years ago, wed, november 24, 2010, 12:00:00
Hallo,
i would like to do something that i thought would be fairly simple:
get the loginName of the current user using the SharePoint2010 Client OM with ECMAScript.
Here is my code:
var currentcontext = new SP.ClientContext.get_current();
var currentweb = currentcontext.get_web();
currentcontext.load(currentweb);
var currentuser = currentweb.get_currentUser();
currentcontext.load(currentuser);
var loginName = currentuser.get_loginName();
the last line throws an exception:
The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
But why? I've loaded the 'currentuser', so why is the 'property or field' not initialized?
More From » sharepoint-2010