Tuesday, 11 November 2014

SharePoint Client Object Model Javascript : JSOM to retrieve an item based on its ID

var item;
Function getItemById(itemId)
{
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var list = web.get_lists().getByTitle('mycustomList');
This.item = list.getItemById(itemId);
clientContext.load(item);
clientContext.executeQueryASync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailure);
}
Function onSuccess()
{
Alert('Success');
}
Function onFailure()
{
Alert('Failure!');
}