Function

$().SPServices

Web Service

Lists

Operation

UpdateList

Notes

  • This operation accepts a webURL option. This allows you to change the context for the operation to a different site. Using a GUID for the listName does NOT change the context as it does with the Object Model, so you need to use the webURL option as well if your list is in a different site.

Examples

This is an example from  MartijnMolegraaf.

// Update default values of the metadata fields
var fieldsToUpdate = '<Fields>';
fieldsToUpdate += '<Method ID="1"><Field Type="Text" Name="ProjectName" DisplayName="Project name"><Default>' + projectName + '</Default></Field></Method>';
fieldsToUpdate += '<Method ID="2"><Field Type="Text" Name="MarinProjectNumber" DisplayName="Project number"><Default>' + projectNumber + '</Default></Field></Method>';
fieldsToUpdate += '<Method ID="3"><Field Type="Text" Name="CustomerNumber" DisplayName="Customer number"><Default>' + customerNumber + '</Default></Field></Method>';
fieldsToUpdate += '<Method ID="4"><Field Type="Text" Name="CustomerName" DisplayName="Customer name"><Default>' + customerName + '</Default></Field></Method>';
fieldsToUpdate += '</Fields>';


$().SPServices({ operation: "UpdateList", listName: "Documents", listProperties:"", updateFields: fieldsToUpdate, newFields: "", deleteFields: "", listVersion: "", async: false, completefunc: function (xData, Status){} });

Last edited Oct 10, 2012 at 3:31 AM by sympmarc, version 3

Comments

grayaj88 Apr 29 at 6:38 PM 
Is there a way to update a list with Site Columns?

codemonkey09 Jul 27, 2015 at 6:53 PM 
Here is an example of enabling versioning. I am doing this right after creation in order to get the version number. Not sure if version is required or not but saw it in the msdn documentation.
$().SPServices({
operation: "AddList",
listName: title,
description:"",
templateID:101,
completefunc: function(xData, Status) {
var version = "";
$(xData.responseXML).find("List").each(function() {
var $list = $(this);
version = $list.attr("Version");
});
$().SPServices(
{
operation: "UpdateList",
listName: title,
listProperties:"<List EnableVersioning='TRUE' />",
updateFields:"",
newFields: "",
deleteFields: "",
listVersion: version,
completefunc: function(xData, Status) {
console.log(xData.responseText);
}
});
} });

AymKdn Jun 20, 2014 at 12:53 PM 
There is an interesting information about the order of the properties and the name we need to use : http://stackoverflow.com/questions/13521292/lists-web-service-updatelist-fails-with-attempted-to-use-an-object-that-has-cea