Friday, January 23, 2015

Update item using CSOM

 <script language="ecmascript" type="text/ecmascript">
    function updateListItem() {
        var clientContext = new SP.ClientContext.get_current();
        var oWeb = clientContext.get_web();
        var oListColl = oWeb.get_lists();
        var oList = oListColl.getByTitle(LISTNAME);    
        var oListItem = oList.getItemById(ITEMID);
        oListItem.set_item('testcolumn', 'Item Updated');
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

    function onQuerySucceeded() {
        alert('Item updated successfully.');
    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
<input onclick="updateListItem()" type="button" value="Update List Item"/>

No comments:

Post a Comment

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...