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"/>

Tuesday, January 20, 2015

Updating a column for a particular item in a list using LINQ

SPListItem resultItem = (from SPListItem oItem in oWeb.Lists["CustomList"].Items
                         where Convert.ToString(oItem["ColumnName"]) == 'Value'
                         select oItem).First();
resultItem["Title"] = "Sample";

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...