Microsoft KB Archive/923902

= Values that were previously associated with a field are reset when you run a custom code that calls the Lists.UpdateList method to update a list view in SharePoint Products and Technologies =

Article ID: 923902

Article Last Modified on 5/14/2007

-

APPLIES TO


 * Microsoft Office SharePoint Server 2007
 * Microsoft Office SharePoint Portal Server 2003
 * Microsoft Windows SharePoint Services 3.0
 * Microsoft Windows SharePoint Services

-



SYMPTOMS
Consider the following scenario. In one of the products that are listed in the &quot;Applies to&quot; section, you create a custom code that references the List.asmx Web service. The code calls the Lists.UpdateList method and adds a field to a list view. The code then updates a property of the field. For example, the code updates the display name of the field. However, when you run the code, the property of the field is not updated as expected. Instead, all the values that were previously associated with the field are reset.

The following code is an example of a code in which you experience these symptoms: // Initialisation - BEGINS PostLists.Lists lst = new TESTBED.PostLists.Lists; lst.Credentials = System.Net.CredentialCache.DefaultCredentials;

XmlNode ndList = lst.GetList(&quot;ListName&quot;); XmlNode ndVersion = ndList.Attributes[&quot;Version&quot;];

XmlDocument xmlDoc = new System.Xml.XmlDocument; XmlNode ndProperties = xmlDoc.CreateNode(XmlNodeType.Element, &quot;List&quot;, &quot;&quot;);

XmlNode ndDeleteFields = xmlDoc.CreateNode(XmlNodeType.Element,&quot;Fields&quot;,&quot;&quot;); XmlNode ndNewFields = xmlDoc.CreateNode(XmlNodeType.Element,&quot;Fields&quot;,&quot;&quot;); XmlNode ndUpdateFields = xmlDoc.CreateNode(XmlNodeType.Element,&quot;Fields&quot;,&quot;&quot;);

XmlAttribute ndTitleAttribute = (XmlAttribute)xmldoc.CreateNode(XmlNodeType.Attribute, &quot;Title&quot;, &quot;&quot;); XmlAttribute ndDescriptionAttribute = (XmlAttribute)xmldoc.CreateNode(XmlNodeType.Attribute, &quot;Description&quot;, &quot;&quot;);

ndTitleAttribute.Value=&quot;ListName&quot;; ndDescriptionAttribute.Value=&quot;Description&quot;;

ndProperties.Attributes.Append(ndTitleAttribute); ndProperties.Attributes.Append(ndDescriptionAttribute);

// Initialisation - ENDS

// STEP1: Add a new Field ndNewFields.InnerXml = &quot;&quot; + &quot;&quot; + &quot; &quot;;

// STEP1.1: Call the Lists.UpdateList method XmlNode ndReturn = lst.UpdateList(&quot;{18D0E90B-20B9-4931-96EB-5435D08532DC}&quot;,                      ndProperties, ndNewFields, null, null,                       ndVersion.Value);

MessageBox.Show(ndReturn.OuterXml);

// STEP2: Update that field ndUpdateFields.InnerXml = &quot;&quot; + &quot;&quot; + &quot;&quot;;

// STEP2.1: Call the Lists.UpdateList method XmlNode ndReturn = lst.UpdateList(&quot;{18D0E90B-20B9-4931-96EB-5435D08532DC}&quot;,                      ndProperties, null, ndUpdateFields, null,                       ndVersion.Value);

MessageBox.Show(ndReturn.OuterXml);



CAUSE
This problem occurs because the Lists.asmx Web service assigns null values to all values that are not explicitly passed in the update operation.



WORKAROUND
To work around this problem, use the Lists.asmx Web service to update the property of the field. To do this, note the original values of the field. Then, when you update the field, pass the original values in addition to the updated values.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
For more information about the Lists.UpdateList method, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/library/lists.lists.updatelist.aspx

Additional query words: wssv3 wss

Keywords: kbprb kbtshoot kbexpertiseinter KB923902

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.