Thursday, October 24, 2013

Get List Item By Id with specified fields in SharePoint JavaScript Object Model

var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
 
//Geting reference to the list
var olist = web.get_lists().getByTitle('Configs');
var oitem = olist.getItemById(1);
//get Title,id,ConfigItem fields
ctx.load(oitem, "Title", "Id", "ConfigItem");
ctx.executeQueryAsync(function () {
 
    alert(oitem.get_item("Title"));
    alert(oitem.get_item("ConfigItem"));
 
}, function (a, b) {
    alert(b.get_message());
});
Post a Comment