0

Is there a method reference for all the gets/sets in the. ECMAScript JavaScript library for sharepoint 2010. I know the obvious answer is MSDN but I have trouble finding anything there. For example I found the JavaScript Library and under SP Namespace I found User....but I am looking for what I can use ( get_title, get_id, get_email...etc) but the only thing there is email. I know there are more more gets than that so I think I just don't understand the structure or how to navigate it....alas does anyone know where I can find a good reference for all the gets and such.

Appreciate it as always.

2

You'll have to check the class it inherits from, the SP.User Class inherits from the SP.Principal Class.

There you find properties like:

  • id
  • loginName
  • principalType
  • title

Another options is to check the properties of the object.

Example:

function runCode() {

     var clientContext = new SP.ClientContext();
     user = clientContext.get_web().get_currentUser();  
     clientContext.load(user);
     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

function onQuerySucceeded() {

    for(var prop in user)
    {
        console.log(prop);
    }
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Output:

enter image description here

  • Thanks once more Anders.... This helps tremendously! Appreciated – Justin Jun 17 '13 at 12:51
  • This is great, I was having the same problem today with correlating the official MS docs (which give you the C# methods) to the actual SP.JS get_xxxx methods. – Thomas Gass Jul 17 '17 at 15:03

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.