I have a strange problem. It occurs totally randomly, I have no idea why and in what circumstances it comes.
Details: I want to get the members of a Group with the executeQueryAsync
function. In the callback the userEnumerator = users.getEnumerator();
row throws this exception:
The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
There is no other async code running. I dont know if this important, but this only happens if this is running at page load.
I insert this code with an XML Viewer
webpart.
var ctx = SP.ClientContext.get_current(),
groups = ctx.get_web().get_siteGroups(),
group = groups.getById(6),
users = group.get_users();
ctx.load(group);
ctx.load(users);
ctx.executeQueryAsync(function () {
var userEnumerator,
user;
$("#members-select").empty();
userEnumerator = users.getEnumerator();
while (userEnumerator.moveNext()) {
user = userEnumerator.get_current();
$("#members-select").append('<option>' + user.get_title() + '</option>');
}
});
Thanks, if anyone knows and shares any information about this. I saw this question as well.