SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function(){
var ctx=new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle("Spotlight Employee");
var query = new SP.CamlQuery();
query.set_viewXml('');
this.listitems=list.getItems(query);
ctx.load(listitems);
ctx.executeQueryAsync(Function.createDelegate(this, function(){
var listEnumerator = listitems.getEnumerator();
var ids=[], users=[], user, i=0;
while (listEnumerator.moveNext()) {
var oField = listEnumerator.get_current();
var id = oField.get_item("UserName").get_lookupId();
users[i] = ctx.get_web().getUserById(id);
ctx.load(users[i++]);
}//End while
ctx.executeQueryAsync(Function.createDelegate(this, function(){
for( i=0; i < users.length;i++){
console.log(users[i].get_loginName());
console.log(users[i].get_title());
}
}), Function.createDelegate(this, this.onFail));
}), Function.createDelegate(this, this.onFail));
});
var ctx=new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle("Spotlight Employee");
var query = new SP.CamlQuery();
query.set_viewXml('');
this.listitems=list.getItems(query);
ctx.load(listitems);
ctx.executeQueryAsync(Function.createDelegate(this, function(){
var listEnumerator = listitems.getEnumerator();
var ids=[], users=[], user, i=0;
while (listEnumerator.moveNext()) {
var oField = listEnumerator.get_current();
var id = oField.get_item("UserName").get_lookupId();
users[i] = ctx.get_web().getUserById(id);
ctx.load(users[i++]);
}//End while
ctx.executeQueryAsync(Function.createDelegate(this, function(){
for( i=0; i < users.length;i++){
console.log(users[i].get_loginName());
console.log(users[i].get_title());
}
}), Function.createDelegate(this, this.onFail));
}), Function.createDelegate(this, this.onFail));
});
No comments:
Post a Comment