p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   .NET Web Services (http://p2p.wrox.com/forumdisplay.php?f=102)
-   -   Sharepoint GetListItems() ViewFields not working (http://p2p.wrox.com/showthread.php?t=69998)

forkhead August 11th, 2008 06:30 PM

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"

samjudson August 12th, 2008 03:16 AM

I think a Sharepoint forum would be better for this question:


However by a simple reading of the docs I could guess that it might have something to do with the IncludeMandatoryColumns value defaulting to TRUE.


/- Sam Judson : Wrox Technical Editor -/

All times are GMT -4. The time now is 07:02 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.