2

I noticed that for a particular list, calling GetListItems and passing null for the viewFields argument, I wasn't getting back all of the columns. Just a few were missing.

After some trial and error, I found that instead of passing null, I could pass in an empty XmlNode like this:

list.GetListItems(
    "listname", 
    null, 
    query, 
    (new XmlDocument()).CreateElement("ViewFields"), 
    null, 
    null, 
    null);

And that gives me all the columns.

I don't see why that is the case. I haven't found anything in the documentation to help me understand what's going on. I have used GetListItems many times on many lists but I've never seen it shortchange me on columns with a null viewFields until today.

Why would the GetListItems behave like this?

Thanks!

3

Specifying null for both the view and the viewfields parameters returns the fields of the default view which may or may not have all the fields. By specifying an empty ViewFields element you are overriding that behavior and asking for all fields.

Reference: http://msdn.microsoft.com/en-us/library/websvclists.lists.getlistitems.aspx

  • That's it! Thank you for your tip! Empty XMLNode gives all the SP-Columns, finally! – user8953 Jun 19 '12 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy