I had written the code to update the Column using ID.And on-success function I am able to see the updated value through alert. But in sharepoint list the column remains with default value.

Can any one help me out of this strange problem

function addprfcode(prfid)
    alert("Now We are In PRFFunciton to Update PRF Code");
    var clientContext = new SP.ClientContext.get_current();
    alert("Got Current SIte");
    var oList = clientContext.get_web().get_lists().getByTitle('PRF');
    alert("Got Current List");
    var camlQuery = new SP.CamlQuery();
    alert("Initialized Caml Query");
    camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>"+prfid +"</Value></Eq></Where></Query></View>");
    alert("Executed the Query");
    this.collListItem = oList.getItems(camlQuery);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.updateprfcode), Function.createDelegate(this, this.onQueryFailed));


function updateprfcode(sender, args)
    var prfcode=document.getElementById("prfidcode").value;
    var listItemEnumerator = collListItem.getEnumerator();
    // alert("listItemEnumerator in PRF  is.."+listItemEnumerator);
    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        alert('Before Updated PRFCODE is ' + oListItem.get_item('GenPRFID'));
        alert('After Updated PRFCODE is ' + oListItem.get_item('GenPRFID'));
        alert("Updated PRF CODE SuccessFully");

  • Seems that you are missing the clientContext.executeQueryAsync() call after the oListItem.update();
    – HarryB
    Commented Aug 15, 2016 at 12:37

1 Answer 1


You can follow below steps for updating

oListItem.set_item('Title', 'My Updated Title');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
  • Note: Function.createDelegate is oldskool code from the old days when IE6 didn't support all JS .bind. It will work because SharePoint has some polyfills, but might notwork in SharePoints "New Experiences" Commented Aug 15, 2016 at 14:02
  • My function addprfcode is already having the clientContext.executeQueryAsync(Function.createDelegate(this, this.updateprfcode), Function.createDelegate(this, this.onQueryFailed));
    – MSA
    Commented Aug 15, 2016 at 14:14
  • It's missing in updateprfcode Commented Aug 15, 2016 at 14:30
  • Can you please let me know in brief.My code is working fine and it is showing the updated value in updateprfcode function.But the values remains in same in List .And how can I write the clientContext.execut‌​eQueryAsync(Function.‌​createDelegate(this, this.updateprfcode), Function.createDeleg‌​ate(this, this.onQueryFailed))‌​; when I am sending the parameters from addprfcode function when there is already written in it
    – MSA
    Commented Aug 16, 2016 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.