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 "Applies to" 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("ListName"); XmlNode ndVersion = ndList.Attributes["Version"]; XmlDocument xmlDoc = new System.Xml.XmlDocument(); XmlNode ndProperties = xmlDoc.CreateNode(XmlNodeType.Element, "List", ""); XmlNode ndDeleteFields = xmlDoc.CreateNode(XmlNodeType.Element,"Fields",""); XmlNode ndNewFields = xmlDoc.CreateNode(XmlNodeType.Element,"Fields",""); XmlNode ndUpdateFields = xmlDoc.CreateNode(XmlNodeType.Element,"Fields",""); XmlAttribute ndTitleAttribute = (XmlAttribute)xmldoc.CreateNode(XmlNodeType.Attribute, "Title", ""); XmlAttribute ndDescriptionAttribute = (XmlAttribute)xmldoc.CreateNode(XmlNodeType.Attribute, "Description", ""); ndTitleAttribute.Value="ListName"; ndDescriptionAttribute.Value="Description"; ndProperties.Attributes.Append(ndTitleAttribute); ndProperties.Attributes.Append(ndDescriptionAttribute); // Initialisation - ENDS // STEP1: Add a new Field ndNewFields.InnerXml = "<Method ID='1'>" + "<Field Type='DateTime' Name='testNewField1' DisplayName='testNewField1 description'>" + " </Method>"; // STEP1.1: Call the Lists.UpdateList method XmlNode ndReturn = lst.UpdateList("{18D0E90B-20B9-4931-96EB-5435D08532DC}", ndProperties, ndNewFields, null , null, ndVersion.Value); MessageBox.Show(ndReturn.OuterXml); // STEP2: Update that field ndUpdateFields.InnerXml = "<Method ID='2'>" + "<Field Type='DateTime' Name='testNewField1' DisplayName='Field1'/>" + "</Method>"; // STEP2.1: Call the Lists.UpdateList method XmlNode ndReturn = lst.UpdateList("{18D0E90B-20B9-4931-96EB-5435D08532DC}", 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 "Applies to" section.
MORE INFORMATION
For more information about the Lists.UpdateList method, visit the following Microsoft Web site:
Additional query words: wssv3 wss
Keywords: kbprb kbtshoot kbexpertiseinter KB923902