Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

SP 2013 - Using Client Side Object Model Doesn't Update Item

$
0
0

Hello Community!

I am using SP 2013 RTM Enterprise and I have created a custom page that uses the SP Client Side Object Model (CSOM) with ECMA Script (JavaScript) to update a list item.  The code is very simple, and the error catcher reports success, but the item is never updated - what am I doing wrong?  Can anyone tell me how to get this to succeed?  The relevant code is shown below...

<script language="ecmascript" type="text/ecmascript">

    function saveToItem(id) {

        var context = new SP.ClientContext("http://c4877270778:8080/sites/variqsolutions/viqds4/");

        var items = context.get_web().get_lists().getByTitle("WR Library");
        var item = items.getItemById(id);
        item["WFTaskFKID"] = "Test";
        item.update();

        context.executeQueryAsync(saveToItemSucceeded, saveToItemFailed);

    }

    function saveToItemSucceeded() {
        alert("Succeeded");
    }

    function saveToItemFailed(sender, args) {
        alert("Failed " + args.get_message());
    }</script>
<!-- VarIQ CSOM Libraries --><script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script><script type="text/javascript" src="/_layouts/15/sp.runtime.debug.js"></script><script type="text/javascript" src="/_layouts/15/sp.debug.js"></script>
<input type="button" value="Reject" name="btnVarIQReject" onclick="saveToItem(8)" />

Thanks!

Tom Molskow


Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award - Linked-In - SharePoint Gypsy


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>