Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

[SP13] JS Async: Manager - People - People details

$
0
0

Hello everyone :-)

I'm facing a problem which is, I think, might be answered somewhere but I don't find :(

So, here it is: I want to get my SharePoint groups of my Site Collection, then the users in, finally the details of this users.

That's what I got:

function getCurrentGroups() {
    this.clientContext = new SP.ClientContext.get_current();
    var oWeb = clientContext.get_web();
	this.allGroups =  oWeb.get_siteGroups();
    this.clientContext.load(allGroups);
    this.clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededGroups), Function.createDelegate(this, this.onQueryFailedGroups));
}

function onQuerySucceededGroups() {
    var groupsEnum = allGroups.getEnumerator();
    while (groupsEnum.moveNext()) {
		console.log(groupsEnum.get_current().get_title() + " : ");
		this.allUsers = groupsEnum.get_current().get_users();
		this.clientContext.load(allUsers);
		this.clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySuccedUser), Function.createDelegate(this, this.onQueryFailedUsers));
    }
}

function onQuerySuccedUser() {
	var usersEnum = allUsers.getEnumerator();
	while (usersEnum.moveNext()) {
		console.log(usersEnum.get_current().get_title());
	}
}

$(document).ready(function() {
	getCurrentGroups();
})

The biggest problem here, is this line:

this.clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySuccedUser), Function.createDelegate(this, this.onQueryFailedUsers));

Because this line is in a loop and the call is async.

How can I manage to do: when the callback come back, continue the loop? Or doing something totally different, if so, tell me how you achieves this?

Thanks in advance.

Regards,
Mafyou.


Cordialement, Mafyou.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>