View Single Post
  #1 (permalink)  
Old August 11th, 2008, 06:30 PM
forkhead forkhead is offline
Authorized User
Join Date: Oct 2003
Location: Golden, CO, USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sharepoint GetListItems() ViewFields not working

Hi Everyone - not sure if this is the right forum - maybe someone can point me in the right direction.

I'm following what I think should work and narrow down my results from the GetListItems() method of Sharepoint 2007.

I'm creating an XML element <ViewFields> and populating it with <FieldRef Name="NewsTitle" /><FieldRef Name="ID" /></ViewFields> and passing it in to the ViewFields argument. But the web service returns *all* fields, no matter what view name I give it (null or the guid).

Any ideas what's going on?

Code posted below

string strReturn = string.Empty;
            vsharepoint2007.Lists L = new WSTest.vsharepoint2007.Lists();
            L.Url = "http://vsharepoint2007:16848/_vti_bin/lists.asmx";
            L.Credentials = new System.Net.NetworkCredential("administrator", "forkhead");
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            string listName = "{A36E3C89-F137-4205-8699-3476D58D82CC}";
            string viewName = "{93B7AAB7-7BCB-4CB4-BCE7-7BA384165698}";
            string rowLimit = "1";
            System.Xml.XmlElement ndQuery = xmlDoc.CreateElement("Query");
            System.Xml.XmlElement ndViewFields = xmlDoc.CreateElement("ViewFields");
            System.Xml.XmlElement ndQueryOptions = xmlDoc.CreateElement("QueryOptions");

            ndQuery.InnerXml = "<Where><Eq><FieldRef Name=\"ID\" />" +
                    "<Value Type=\"Counter\">1</Value>" +
            ndViewFields.InnerXml = "<FieldRef Name=\"NewsTitle\" /><FieldRef Name=\"ID\" />";
            ndQueryOptions.InnerXml = "";
            System.Xml.XmlNode nodeListItems = L.GetListItems(listName, null, ndQuery, ndViewFields, rowLimit, ndQueryOptions, null);

            foreach (System.Xml.XmlNode X in nodeListItems)
                strReturn += X.OuterXml;
            return strReturn;

"A spirit with a vision is a dream with a mission"
\"A spirit with a vision is a dream with a mission\"
Reply With Quote