Microsoft Knowledge Base Email Alertz

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 Windows SharePoint Services 3.0 or in SharePoint Portal Server 2003

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 923902 - Last Review: May 14, 2007 - Revision: 2.4

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

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:
http://msdn2.microsoft.com/en-us/library/lists.lists.updatelist.aspx (http://msdn2.microsoft.com/en-us/library/lists.lists.updatelist.aspx)

APPLIES TO
  • Microsoft Office SharePoint Server 2007
  • Microsoft Office SharePoint Portal Server 2003
  • Microsoft Windows SharePoint Services 3.0
  • Microsoft Windows SharePoint Services 2.0
Keywords: 
kbtshoot kbprb kbexpertiseinter KB923902
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate