1

I've got a problem with not being able to select a single list item from the User Information List, I have used U2U CAMLbuilder to build a query that extracts an entry with the ID = 1 When run in the CAMLbuilder the query returns a single valid item. But when the query is executed in javascript client object model code it returns: "all available users". This is unacceptable performance-wise.

The query itself seems to be correct, as I've said I've verified it in CAMLbuilder and also had it reviewed by a colleague. So I'm wondering if there might be any known issues with selecting items from the User Information List.

2 Answers 2

1

You should be able to just use:

SPList list = SPContext.Current.Web.SiteUserInfoList;
SPListItem item = list.GetItemById(SPContext.Current.Web.CurrentUser.ID);
0

I think your query must be correct but you might be calling it in a wrong way. See my answer here for the correct form of using the caml query with the client object model.

no sorting with JavaScript Client Object Model?

Also, if you have to get only 1 user by ID, then you won't require the CAML query. You can use the code Jasper has provided. Only thing is that code is from the .NET managed client object model. The code in the javascript client object model will be similar to this:

var clientContext = new SP.ClientContext.get_current();

var web = clientContext.get_web();

var userInfoList = web.get_siteUserInfoList();

this.itemUser = userInfoList.getItemById(1);

clientContext.load(itemUser);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));


function onQuerySucceeded(sender, args)
{
    alert(itemUser.get_item("Title"));
}
function onQueryFailed(sender, args)
{
    alert(args.get_message());
}

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.