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

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.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();


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 (

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

Your Answer


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

Browse other questions tagged or ask your own question.