Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to use the GetListItems web service in MOSS 2007 to return all the columns and rows in custom SharePoint list. I don't need to filter any of the data, so I've left the QueryOptions and Query nodes empty.

I have copied and pasted the CAML below. As you can see from the query result, the xmlnode is not returning the custom meta data columns I've defined on the list. Here's the CAML Query:

Dim xmlDoc As XmlDocument = New System.Xml.XmlDocument()

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

ndQuery.InnerXml = "<Query />"
ndQueryOptions.InnerXml = "<QueryOptions />"
ndViewFields.InnerXml = "<ViewFields>" + _
                             "<FieldRef Name='Title' />" + _
                             "<FieldRef Name='Account_x0020_Number' />" + _
                             "<FieldRef Name='Address_x0020_1' />" + _
                             "<FieldRef Name='Address_x0020_2' />" + _
                             "<FieldRef Name='Address_x0020_3' />" + _
                             "<FieldRef Name='Country' />" + _
                             "<FieldRef Name='Bank_x0020_Name' />" + _
                             "<FieldRef Name='Bank_x0020_Address' />" + _
                             "<FieldRef Name='Bank_x0020_Swift_x0020_Code' />" + _
                             "<FieldRef Name='Intermediary_x0020_Bank' />" + _
                             "<FieldRef Name='Intermediary_x0020_Bank_x0020_Ac' />" + _
                             "<FieldRef Name='Intermediary_x0020_Bank_x0020_Sw' />" + _
                             "<FieldRef Name='Intermediary_x0020_Bank_x0020_AB' />" + _
                             "<FieldRef Name='Corp' />" + _
                        "</ViewFields>"

Dim strListId As String = "{AF558681-E8A7-453A-ABE7-D2EA3AF46F25}"
Dim strViewId As String = "{989C4CE4-3361-4BAC-BA81-911B65857559}"

Dim ndListItems As XmlNode = lists_ws.GetListItems(strListId, strViewId, ndQuery, ndViewFields, String.Empty, ndQueryOptions, String.Empty)

This is the query result (outer XML fragment):

<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<rs:data ItemCount="3">
   <z:row ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Cardanias" ows_ID="1" ows_owshiddenversion="2" ows_UniqueId="1;#{4131F39F-062E-48AA-A886-83102053B112}" ows_FSObjType="1;#0" ows_Created="2011-05-20 10:00:35" ows_FileRef="1;#Finance/Xfer/Lists/Payees/1_.000" />
   <z:row ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Blue Ocean A/S" ows_ID="2" ows_owshiddenversion="1" ows_UniqueId="2;#{94DCB1C4-1C42-478D-839E-1CA3E82BDA53}" ows_FSObjType="2;#0" ows_Created="2011-05-20 10:00:42" ows_FileRef="2;#Finance/Xfer/Lists/Payees/2_.000" />
   <z:row ows_MetaInfo="3;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Asia Ltd." ows_ID="3" ows_owshiddenversion="1" ows_UniqueId="3;#{39D53595-3D2B-45AA-8E40-3766498C4050}" ows_FSObjType="3;#0" ows_Created="2011-05-20 10:00:51" ows_FileRef="3;#Finance/Xfer/Lists/Payees/3_.000" />
</rs:data>
</listitems>

I'm not getting back the columns I've requested in the "ViewFields" node. I've tried setting the QueryOptions to "IncludeMandatoryColumns = FALSE and TRUE, but neither has seemed to affect the OuterXML coming back.

I would expect to see the custom meta data column values that I specified in the tags?

Is there something I'm missing here?

Thanks in advance...

share|improve this question
    
What's the contents of your ndViewFields (break execution, add a watch or check with immediate) after it's been built? –  James Love May 23 '11 at 18:24
    
Do the missing fields have values? If a field is empty, then it will not be included in the response XML. –  Laurie May 23 '11 at 19:17
add comment

2 Answers 2

up vote 5 down vote accepted

Try removing the duplicate <ViewFields> node:

ndViewFields.InnerXml = "<FieldRef Name='Title' />" + _
                         "<FieldRef Name='Account_x0020_Number' />" + _
                         "<FieldRef Name='Address_x0020_1' />" + _
                         "<FieldRef Name='Address_x0020_2' />" + _
                         "<FieldRef Name='Address_x0020_3' />" + _
                         "<FieldRef Name='Country' />" + _
                         "<FieldRef Name='Bank_x0020_Name' />" + _
                         "<FieldRef Name='Bank_x0020_Address' />" + _
                         "<FieldRef Name='Bank_x0020_Swift_x0020_Code' />" + _
                         "<FieldRef Name='Intermediary_x0020_Bank' />" + _
                         "<FieldRef Name='Intermediary_x0020_Bank_x0020_Ac' />" + _
                         "<FieldRef Name='Intermediary_x0020_Bank_x0020_Sw' />" + _
                         "<FieldRef Name='Intermediary_x0020_Bank_x0020_AB' />" + _
                         "<FieldRef Name='Corp' />"
share|improve this answer
    
Beat me! +1 for a great answer. –  theChrisKent May 23 '11 at 19:34
    
If this (and Chris) is right, then my suspicions were right, hence I asked him to paste the results of his nvViewFields property from a breakpoint - should've gone with my hunch and posted an answer ;) –  James Love May 23 '11 at 19:48
    
@James: Luckily I had my web services testing project open so it was easy for me to test. :) –  Kit Menke May 23 '11 at 19:51
add comment

The problem is you are creating invalid nodes. For instance, using your code your XML will look like this:

Query Node:

<Query>
    <Query/>
</Query

There is no need to set the InnerXML property for your ndQuery or ndQueryOptions nodes. Ultimately the problem with your ViewFields is the same, your XML looks something like:

<ViewFields>
    <ViewFields>
        <FieldRef Name='Title' />
        ...
    </ViewFields>
</ViewFields>

So to fix, just remove the extra <ViewFields> element by setting the InnerXML like this:

ndViewFields.InnerXml = "<FieldRef Name='Title' />" + _
                        "<FieldRef Name='Account_x0020_Number' />" + _
                        "<FieldRef Name='Address_x0020_1' />" + _
                        "<FieldRef Name='Address_x0020_2' />" + _
                        "<FieldRef Name='Address_x0020_3' />" + _
                        "<FieldRef Name='Country' />" + _
                        "<FieldRef Name='Bank_x0020_Name' />" + _
                        "<FieldRef Name='Bank_x0020_Address' />" + _
                        "<FieldRef Name='Bank_x0020_Swift_x0020_Code' />" + _
                        "<FieldRef Name='Intermediary_x0020_Bank' />" + _
                        "<FieldRef Name='Intermediary_x0020_Bank_x0020_Ac' />" + _
                        "<FieldRef Name='Intermediary_x0020_Bank_x0020_Sw' />" + _
                        "<FieldRef Name='Intermediary_x0020_Bank_x0020_AB' />" + _
                        "<FieldRef Name='Corp' />"
share|improve this answer
    
Thanks for all the help! That did the trick. I appreciate all the feedback, and fast assistance! –  drew-m May 23 '11 at 19:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.