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 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!

share|improve this question
add comment

1 Answer

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

share|improve this answer
    
That's it! Thank you for your tip! Empty XMLNode gives all the SP-Columns, finally! –  user8953 Jun 19 '12 at 12:38
add comment

Your Answer

 
discard

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