I am trying to get specific users with this line using ECMA but I keep getting error:

this.oUser = cxt.get_web().get_siteUsers().getByLoginName('dev\\joe');

I keep getting property or method get_siteUsers() not supported....but I am taking this from MSDN, so I am not sure if there is something else? Here is the whole function:

function setProjectPermissionsScheme() {

        // I did change from new SP.ClientContext(siteUrl) to get_current but tried both ways and it didn't change outcome
             var clientContext = SP.ClientContext.get_current();
        var oList = clientContext.get_web().get_lists().getByTitle('Projects');
        var itemId = globProjectID;
        this.oListItem = oList.getItemById(itemId);

             // stuck....if I made this currentUser, the whole thing works, but I need to have something like below that will allow me to loop through an object of users and pass each one into this, not just the current.
        this.oUser = cxt.get_web().get_siteUsers().getByLoginName('dev\\joe');

        var collRoleDefinitionBinding = SP.RoleDefinitionBindingCollection.newObject(clientContext);
        oListItem.get_roleAssignments().add(oUser, collRoleDefinitionBinding);
        var collRoleDefinitionBinding = SP.RoleDefinitionBindingCollection.newObject(clientContext);
        oListItem.get_roleAssignments().add(oUser, collRoleDefinitionBinding);
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onSetProjectPermissionsSucceeded), Function.createDelegate(this, this.onQueryFailed));
function onSetProjectPermissionsSucceeded(sender, args) {

    alert('Role inheritance broken for item ' + 
        this.oListItem.get_item('Title') + 
        ' and new role assignment for ' + 

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

I found get_siteUsers() here and this is what I am trying to do. Any help is greatly appreciated.

  • Hi Justin, are you working with SharePoint 2010 or 2013? Please add a tag to your question with the version. – Vardhaman Deshpande Jul 28 '13 at 7:51
  • Hey. SP 2010 is what I am working on. – Justin Jul 28 '13 at 11:39

The SP.Web.get_siteUsers() property is part of the SharePoint 2013 JavaScript API and is not part of the SP 2010 JSOM. That is the reason why you are getting the property unsupported error.

This is the reference for SP 2010: http://msdn.microsoft.com/en-us/library/ee549149(v=office.14).aspx

And this is for SP 2013: http://msdn.microsoft.com/en-us/library/jj245288.aspx

Hope this clears it up.

| improve this answer | |
  • sure does...must have somehow wondered over and not even realized it (fail). appreciate the clarification. I have since handled this another round about way by including all the users I need into several groups, getting the current user, adding all those users to a custom object, creating a new group and filling it with users from the object.....unless there is a better way? – Justin Jul 29 '13 at 2:09

First step is to retrieve the user and then load the user.

var currcontext = new SP.ClientContext.get_current();

var currweb = currcontext.get_web();

currcontext .load(currweb);

var curruser = currweb.get_currentUser();



var loginName = curruser.get_loginName();

For more refer to ... http://pankaj-sharepoint2010part28.blogspot.in/

How to get current user with javascript?

| improve this answer | |

Ensure that your code runs after SP.js finishes loading. You can do so by putting function call inside a js function as shown below:

ExecuteOrDelayUntilScriptLoaded(setProjectPermissionsScheme, "sp.js");
| improve this answer | |
  • thanks Falak. yeah I accounted for the lazy loading, as I have much more going on within the page (updates, creates, etc). – Justin Jul 21 '13 at 11:17
  • ExecuteOrDelayUntilScriptLoaded ensures that all of the built-in SharePoint features are loaded, enabling the toolbar interface to work properly, while still allowing for custom scripts that manipulate page content. BTW, did it help so mark it as an answer. – Falak Mahmood Jul 21 '13 at 15:53
  • yeah i understand...i meant i am already using ExecuteOrDelayUntilScriptLoaded in my document ready as the above isn't the only COM operation I have going on in this page. If I try and get the current User it works fine, but when I try the get_siteUsers it tells me that there is no property for web. – Justin Jul 25 '13 at 1:13

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.