1

I am trying to update my list. My codes already worked but I don't know what happened. When I designed my page, then hit Ctrl +S, then upload it again to share point, the codes didn't run already. I have deadline.

When I click table row, information goes to text box. When I change something in the tex tbox and clicked button, the table should update, but in my codes, it doesn't work.

Here's my code for SP Services: I don't know if I miss something or if I deleted something. I'll appreciate your answers. I hope for fast replies. Thanks a lot!

function Updatethis(){
    var method = "UpdateListItems";
    var list = "RFA_BODIList";
    var id=document.getElementById('ID').value;
    var supfunc=document.getElementById('supfunc').value;
    var tn=document.getElementById('tn').value;
    var td=document.getElementById('td').value;
    var ttype=document.getElementById('ttype').value;
    var prio=document.getElementById('prio').value;
    var func=document.getElementById('func').value;
    var req=document.getElementById('req').value;
    var rsum=document.getElementById('rsum').value;

    var fieldsToRead = "<ViewFields>" +
        "<FieldRef Name='ID' />" +
        "<FieldRef Name='Title' />" +
        "<FieldRef Name='TicketNumber' />" +
        "<FieldRef Name='TicketDescription' />" +
        "<FieldRef Name='TicketType' />" +
        "<FieldRef Name='Priority' />" +
        "<FieldRef Name='RequestorFunctionalArea' />" +
        "<FieldRef Name='Requestor' />" +
        "<FieldRef Name='RequestSummary' />" +
        "<FieldRef Name='RequestDate' />" +
        "<FieldRef Name='Status' />" +
        "</ViewFields>";

   var query = "<Query>" +
                    "<Where>" +
                            "<Eq>" +
                                "<FieldRef Name='ID'/><Value Type='Number'>" + id + "</Value>" +
                            "</Eq>" +
                    "</Where>" +
                "</Query>";

    $().SPServices({
            operation: method,
            async: false,
            listName: list,
            CAMLViewFields: fieldsToRead,
            CAMLQuery: query,
            updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
                        "<Method ID='1' Cmd='Update'>" +
                            "<Field Name='ID'>" + id + "</Field>" +
                            "<Field Name='Title'>" + supfunc + "</Field>" +
                            "<Field Name='TicketNumber'>" + tn + "</Field>" +
                            "<Field Name='TicketDescription'>" + td + "</Field>" +
                            "<Field Name='TicketType'>" + ttype + "</Field>" +
                            "<Field Name='Priority'>" + prio + "</Field>" +
                            "<Field Name='FunctionalArea'>" + func + "</Field>" +
                            "<Field Name='Requestor'>" + req + "</Field>" +
                            "<Field Name='RequestSummary'>" + rsum + "</Field>" +
                        "</Method>" +
                    "</Batch>",
            completefunc: function (xData, Status) {


            alert(updates);
            alert(id);
            alert(supfunc);
            alert(tn);
            alert(td);
            alert(ttype);
            alert(prio);
            alert(func);
            alert(req);



            //location.reload();
            }
   });
}

Here's my codes for text boxes and button:

 <div class="inputWrapper" style="margin-top: 40px;">
<input type="text" id="ID"/>
<input type="text" id="supfunc"/>
<input type="text" id="tn"/>
<input type="text" id="td"/>
<input type="text" id="ttype"/>
<input type="text" id="prio"/>
<input type="text" id="func"/>
<input type="text" id="req"/>
<input type="text" id="rsum"/>

</div> <input type="button" value="Update" class="Updatethis" onclick="Updatethis()"/>

1 Answer 1

0

I already figured it out.

If you can see: The Name of my <FieldRef Name = 'RequestorFunctionalArea'/> here...(see below)

var fieldsToRead = "<ViewFields>" +
    "<FieldRef Name='ID' />" +
    "<FieldRef Name='Title' />" +
    "<FieldRef Name='TicketNumber' />" +
    "<FieldRef Name='TicketDescription' />" +
    "<FieldRef Name='TicketType' />" +
    "<FieldRef Name='Priority' />" +
    "<FieldRef Name='RequestorFunctionalArea' />" +
    "<FieldRef Name='Requestor' />" +
    "<FieldRef Name='RequestSummary' />" +
    "<FieldRef Name='RequestDate' />" +
    "<FieldRef Name='Status' />" +
    "</ViewFields>";

is different to my "<Field Name='FunctionalArea'>" + func + "</Field>". See below.

 updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
                    "<Method ID='1' Cmd='Update'>" +
                        "<Field Name='ID'>" + id + "</Field>" +
                        "<Field Name='Title'>" + supfunc + "</Field>" +
                        "<Field Name='TicketNumber'>" + tn + "</Field>" +
                        "<Field Name='TicketDescription'>" + td + "</Field>" +
                        "<Field Name='TicketType'>" + ttype + "</Field>" +
                        "<Field Name='Priority'>" + prio + "</Field>" +
                        "<Field Name='FunctionalArea'>" + func + "</Field>" +
                        "<Field Name='Requestor'>" + req + "</Field>" +
                        "<Field Name='RequestSummary'>" + rsum + "</Field>" +
                    "</Method>" +
                "</Batch>",

Just change the Name, and tada! It will work! They should have the same name. I just overlooked it.

I hope this will help others. Thank you for reading.

To God be the glory!

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.