operation:updatelistitems not fully working...

May 22, 2013 at 4:18 PM
Edited May 22, 2013 at 4:23 PM
Hi All,

I am new using "UpdatelistItems" operation and need help please. I have a simple form and I want to be able to insert data into a sharepoint 2010 list upon clicking submit button. When the user clicks submit, I get no errors but only the first two fields("DeliverableName" and "FY") gets submitted into the list. I've done everything like make sure the internal name is right and I've done alerts to make sure a value is being inserted but nothing seems to work. Am I missing something?


<table border="0" style="width: 45%">
<tr>
<td style="background-color:#eeeeee">
    <table class="formtbl" style="width: 100%" cellspacing="1" cellpadding="2">
                    <tr>
                                    <td colspan="2" style="width:313px;font-weight:bold;text-align:left"><h2>Add a New Deliverable</h2></td>
                    </tr>
                    <tr>
                                    <td style="width: 313px;font-weight:bold" class="bgColor">Deliverable Name</td>
                                    <td class="bgColor"><input name="DeliverableName" type="text" id="txtDeliverableName"></td>
                    </tr>
                    <tr>
                                    <td style="width: 313px;font-weight:bold" class="bgColor">FY</td>
                                    <td class="bgColorElement">
                                      <select name="Select1" id="drpdFY">
                                        <option value=""></option>
                                        <option value="2013">2013</option>
                                        <option value="2013">2014</option>
                                        <option value="2013">2015</option>
                                      </select>
                                    </td>
                    </tr>
                    <tr>
                                    <td style="width: 313px;font-weight:bold" class="bgColor">Activity</td>
                                    <td class="bgColorElement">
                                      <select name="Select2" id="drpdActivity">
                                        <option value=""></option>
                                        <option value="Test">Test</option>
                                        <option value="Cross-Cutting">Cross-Cutting</option>
                                        <option value="Networking">Networking</option>
                                        <option value="Other">Other</option>
                                        <option value="Terminals"> Terminals</option>
                                        <option value="Tactical ">Tactical </option>
                                      </select>
                                    </td>
                    </tr>
                    <tr>
                                    <td style="width: 313px;font-weight:bold" class="bgColor">Function</td>
                                    <td class="bgColorElement">
                                        <select name="Select3" id="drpdFunction">
                                          <option value=""></option>
                                          <option value="Aobs">Aobs</option>
                                          <option value="Assessments">Assessments</option>
                                          <option value="Resource Allocatiion">Resource Allocatiion</option>
                                          <option value="Systems Eng.">Systems Eng.</option>
                                          <option value="Oversight">Oversight</option>
                                          <option value="Oversight">Oversight</option>
                                          <option value="OTHER">OTHER</option>                                                                                                                                                                                                                                                
                                        </select>
                                    </td>
                    </tr>
                    <tr>
                                    <td style="width: 313px; height: 29px;font-weight:bold" class="bgColor">Project</td>
                                    <td style="height: 29px" class="bgColorElement"><input name="Text2" type="text" id="txtProject"></td>
                    </tr>
                    <tr>
                                    <td style="width: 313px;font-weight:bold" class="bgColor">Government Lead</td>
                                    <td class="bgColorElement">
                                        <select id="drpdGovtLead">
                                          <option value=""></option>
                                          <option value="Jango">Jango</option>
                                          <option value="Sussie">Sussie</option>
                                          <option value="John">John</option>
                                          <option value="Mike">Mike</option>
                                          <option value="Cowboy">Cowboy</option>
                                          <option value="Brown">Brown</option>
                                          <option value="Lucy">Lucy</option>
                                          <option value="jack">jack</option>                                                                                                                                                                                                                                                                                          
                                        </select>
                                    </td>
                    </tr>
                    <tr>
                                    <td style="width: 313px;font-weight:bold" class="bgColor">Product</td>
                                    <td class="bgColorElement"><input type="text" id="txtProduct"></td>
                    </tr>
                
                    <tr>
                                    <td colspan="2" class="bgColorElement">
                                    <input type="submit" id="SubmitButton" value="Submit" onclick="SubmitButtonClick(this)">
                                    &nbsp;</td>
                    </tr>
    </table>
</td>
</tr>
</table>

<!-- Begin Javascript and JQuery -->
<script type="text/javascript" src="http://win-2n0d15326id:11275/myportal/js/jquery-1.8.2.min.js" language="javascript"></script>
<script type="text/javascript" src="http://win-2n0d15326id:11275/myportal/js/jquery.SPServices-0.7.2.min.js" language="javascript"></script>
<script type="text/javascript" src="http://win-2n0d15326id:11275/myportal/js/jquery-ui-LatestVersion.js" language="javascript"></script>
<link rel="stylesheet" type="text/css" href="http://win-2n0d15326id:11275/myportal/style/jquery-ui-LatestVersion.css">

<script type="text/javascript">

$(function() {
    $( "#StartDate" ).datepicker();
    $( "#EndDate" ).datepicker();
    $( "#CompletionDate" ).datepicker();
  });
  

$(document).ready(function() {
 
    // Gets the current sites URL
    currSiteUrl = $().SPServices.SPGetCurrentSite();



});


function SubmitButtonClick(element)
{
//alert("HELLO");
//alert($().SPServices.SPGetCurrentSite());
alert($("#drpdActivity").val());    
    //
    var DeliverableName = $("#txtDeliverableName").val();
    var FY = $("#drpdFY").val();
    var Activity = $("#drpdActivity").val();
    var Project = $("#txtProject").val();
    var Product = $("#txtProduct").val();
    var GovtLead = $("#drpdGovtLead").val();    
    
    $().SPServices(
                {
                    operation: "UpdateListItems",
                    listName: "Deliverables",
                    async: false,                   
                    updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
                        "<Method ID='1' Cmd='New'>" +
                            "<Field Name='Title'>"+DeliverableName+"</Field>" +
                            "<Field Name='FY'>" +FY+ "</Field>" +
                            "<Field Name='Activity'>"+Activity+"</Field>" +
                            "<Field Name='Function'>" + Function  + "</Field>" +                                
                            "<Field Name='Project'>" +Project+ "</Field>" +                     
                        "</Method>" +
                    "</Batch>",
                    completefunc: function(xData, Status) 
                    {
                        //SaveRisks();
                    }
});

}
</script>
Coordinator
May 24, 2013 at 3:58 AM
Probably the best suggestion I can make is to look at the Net traffic with Firebug to make sure that the values you think you are sending are actually in the POST content. You should also look at the response for errors. You also need to be passing the values in te right format for the underlying column types.

M.