function AddListItem() {
try {
//Get the context, web, and the list
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var list = web.get_lists().getByTitle('TheList');
//Add new list item
var itemCreationInfo = new SP.ListItemCreationInformation();
var newitem = list.addItem(itemCreationInfo);
newitem.set_item("Title", "New List Item added with JavaScript and COM");
newitem.update();
ctx.executeQueryAsync(onSucceededCallback, onFailedCallback);
}
catch (e) {
alert(e);
}
}
function onSucceededCallback() {
alert('New list item is added');
}
function onFailedCallback() {
alert('Error: ' + args.get_message());
}
Ingen kommentarer:
Send en kommentar