Thursday 6 October 2011

Get user information list with Javascript client object model SharePoint 2010


To get users from the hidden user information list we will use get_siteUserInfoList() method of Javascript\ecmascript client object model.

Here is an example how to get it

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

var web = clientContext.get_web();

var userInfoList = web.get_siteUserInfoList();

var camlQuery = new SP.CamlQuery();

camlQuery.set_viewXml(‘<View><Query><Where><Eq><FieldRef Name=\’ID\’/>’ +’<Value Type=\’Number\’>’ + userID + ‘</Value></Eq>’ +

‘</Where></Query><RowLimit>1</RowLimit></View>’);

this.collListItem = userInfoList.getItems(camlQuery);

clientContext.load(collListItem);

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

function onQuerySucceeded(sender, args)
{

var item = collListItem.itemAt(0);

var profileNotes = item.get_item('Notes');
alert(profileNotes);
}
function onQueryFailed(sender, args)
{
}

Ads by Google

No comments:

Post a Comment