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');
        oListItem.update();       
        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());
    }
</script>
<input onclick="updateListItem()" type="button" value="Update List Item"/>

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell