Ask a questionAsk a question
 

AnswerWeb Service doesnt return the Added column

  • Wednesday, November 04, 2009 2:50 AMJohnBGood Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    After adding a text field to a my list, the "GetListItems" method of the Lists.asmx web service does not return the newly added column.  Is this the standard behavior of the web service?  Thanks.

Answers

  • Wednesday, November 04, 2009 3:19 AMHereICome SharePoint Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi JohnBGood, first pl make sure your column is added to your list.  second, pl put your code snippet here that you are using to call GetListItems method to return list items. 

    listSvc.Lists list = new spConsole.listService.Lists();
    list.Credentials = System.Net.CredentialCache.DefaultCredentials;

    XmlDocument xmlDoc = new System.Xml.XmlDocument();

    XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element,"Query","");
    XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");
    XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions","");

    ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
        "<DateInUtc>TRUE</DateInUtc>";
    ndViewFields.InnerXml = "<FieldRef Name='Field1' /><FieldRef Name='Field2'/>";
    ndQuery.InnerXml = "<Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Completed</Value></Eq></Where>";

    try
    {
        XmlNode ndListItems = list.GetListItems("List_Name", null, ndQuery, ndViewFields, null, ndQueryOptions, null);
        MessageBox.Show(ndListItems.OuterXml);
    }
    catch (System.Web.Services.Protocols.SoapException ex)
    {
        MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace);
    }

All Replies

  • Wednesday, November 04, 2009 3:19 AMHereICome SharePoint Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi JohnBGood, first pl make sure your column is added to your list.  second, pl put your code snippet here that you are using to call GetListItems method to return list items. 

    listSvc.Lists list = new spConsole.listService.Lists();
    list.Credentials = System.Net.CredentialCache.DefaultCredentials;

    XmlDocument xmlDoc = new System.Xml.XmlDocument();

    XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element,"Query","");
    XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");
    XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions","");

    ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
        "<DateInUtc>TRUE</DateInUtc>";
    ndViewFields.InnerXml = "<FieldRef Name='Field1' /><FieldRef Name='Field2'/>";
    ndQuery.InnerXml = "<Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Completed</Value></Eq></Where>";

    try
    {
        XmlNode ndListItems = list.GetListItems("List_Name", null, ndQuery, ndViewFields, null, ndQueryOptions, null);
        MessageBox.Show(ndListItems.OuterXml);
    }
    catch (System.Web.Services.Protocols.SoapException ex)
    {
        MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace);
    }