Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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);
share|improve this answer
    
Trying to do this very thing but in JSOM...for an Office 365 app, great post. –  Stephen Jan 9 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 at 19:54
    
@Stephen, no. It is a custom function which combine expressions with <or> tag. –  Alexander Jan 10 at 8:09
add comment

Your Answer

 
discard

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

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