**May 20, 2010 Update
My problem started with a simple change to a site column. I had originally created a Country field with the following values:
After a change in requirements, the new values for the field were:
- Great Britain
- United States
After updating the site column, I then needed to update the hundreds of items in the list to use “United States” instead of “US”. Instead of updating hundreds of items manually, I decided to write a small web services console app. (I was also not able to update it in datasheet… due to content approval maybe???)
However, I quickly ran into problems when attempting to update the multi-select choice field.
My site column was defined with each choice for Country in alphabetical order:
The symptoms of my problem were very strange. After running my app successfully, it seemed as if my updates were simply ignored by the server.
- The item is successfully updated using the Lists.asmx (it even creates a new version!)
- The item does not show the updated value for your multi-select choice field in the UI.
Here is the very simple code that is creating the update message:
private static void AddCountryUpdate(ref StringBuilder sb, int count, string id, string newCountry)
Calling the following code to update:
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.InnerXml = sb.ToString();
XmlNode ndReturn = list.ListWebSvc.UpdateListItems(listName, elBatch);
Attempting to update Country to be “;#United States;#Canada;#” resulted in a “success” response (error code of 0x00000000) even when the update was NOT successful:
ows_ID="1311" ows_Country=";#United States;#Canada;#" ows_Modified="2009-10-29 16:01:05" ows__UIVersionString="6.0" />
Viewing this in the UI still shows the old value:
However, only after the values are in order, “;#Canada;#United States;#”, will the update actually happen.
ows_ID="1311" ows_Country=";#Canada;#United States;#" ows_Modified="2009-10-30 08:51:45" ows__UIVersionString="7.0" />
Viewing this in the UI shows the updated value:
Notice it still created a version 6.0 and 7.0:
When updating a multi-select choice field using SharePoint’s Lists.asmx web service, the order of the choices in the update message are important. If they are out of order, it will not update.