Thursday, February 14, 2013

Insert a row into a list using JQuery and Web Services


Requirement: Insert a row in the list using jQuery and Web Services.

Variables (not initiating here, as the values are dynamically generated by another method)
   - allTeamMembers (user name)
   - firstSaturday (date)
Project_Name is a lookup field, the values for lookup field should be the combination of ID of item in the Lookup list and the lookup value

$().SPServices({
  operation: "UpdateListItems",
  async: false,
  batchCmd: "New",
  listName: "Resource Allocation List",
  valuepairs: [["pcompleted",0],["TeamMember",allTeamMembers],["Title","Dummy Entry"],["Week_Ending",firstSaturday],["Project_Name","20;#Others"]],
  completefunc: function(xData, Status) {
msgData = xData.responseText;
  isError = msgData.indexOf("ErrorText");
            if (isError > 0) {
                alert("Error creating missing entries!");
                errorOccured = true;

            }
  }
  });

No comments:

Post a Comment