SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

having trouble getting users return from specified group using javascript per this on MSDN

var siteUrl = '/sites/MySiteCollection ';

function retrieveAllUsersInGroup() {

    var clientContext = new SP.ClientContext(siteUrl);
    var collGroup = clientContext.get_web().get_siteGroups();
    var oGroup = collGroup.getById(7);
    this.collUser = oGroup.get_users();
    clientContext.load(collUser);


    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {

    var userInfo = '';

    var userEnumerator = collUser.getEnumerator();
    while (userEnumerator.moveNext()) {
        var oUser = userEnumerator.get_current();
        this.userInfo += '\nUser: ' + oUser.get_title() + 
            '\nID: ' + oUser.get_id() + 
            '\nEmail: ' + oUser.get_email() + 
            '\nLogin Name: ' + oUser.get_loginName();
    }

    alert(userInfo);
}

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

i only modified it slightly on dev machine just to get started but I get collUser is undefined in the successful callback no matter what i try.....

tried replacing SP.ClientContext(siteUrl) with .get_current() as this is pretty much what i always do.

the site is a subsite that disinherits from the parent....does this have anything to do with it...i don't see that mentioned in the article (http://msdn.microsoft.com/en-us/library/hh185012(v=office.14).aspx)

thanks as always for any help; probably something simple i am missing but ??

share|improve this question
    
If collUser is undefined it should not have anything to do with inherits or not, and the group exists I guess, else you would end up in the failed function. Have you tried referencing it with this.collUser.getEnumerator() ? – Anders Aune Jul 19 '14 at 14:17

Remove this keyword from this.userInfo.

share|improve this answer
    
Can you please provide more details. – Asad Refai Apr 20 at 5:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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