2

I have a dynamically created array of user logins, I would like to retrieve information about these users through CSOM. I found this great post, but there is explanation how to retrieve all users from group. How can I specify that I need to retrieve info only for users in my array?

1 Answer 1

1

For my project I used User Information List, but I don't think that it is a good solution

var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[clientId + "_TopSpan"];
var users = peoplePicker.GetAllUserInfo();

var _ctx = new SP.ClientContext(_spPageContextInfo.webAbsoluteUrl);

var expressions = new Array();
for (var i = 0; i < users.length; i++) {
    expressions.push("<Eq><FieldRef Name='Name' /><Value Type='Text'>" + users[i].Key + "</Value></Eq>");
}

var query = new SP.CamlQuery();
query.set_viewXml("<View><Query><Where>" + buidQueryFromExpressions(expressions) + "</Where></Query></View>");

var list = _ctx.get_web().get_siteUserInfoList();

_loadUsers = list.getItems(query);

_ctx.load(_loadUsers);
3
  • Trying to do this very thing but in JSOM...for an Office 365 app, great post.
    – Stephen
    Jan 9, 2014 at 19:46
  • When i run this i get an error buidQueryFromExpressions is not defined, is this because you are using CSOM and I'm JSOM?
    – Stephen
    Jan 9, 2014 at 19:54
  • @Stephen, no. It is a custom function which combine expressions with <or> tag.
    – Alexander
    Jan 10, 2014 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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