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 found myself working with the Lists.GetListItems method fairly often. Unfortunately, I have never understood what the IncludeMandatoryColumns query option actually does. The documentation seems to imply that when set to FALSE it should only return columns specified in your viewFields parameter.

<QueryOptions>
   <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
</QueryOptions>

Further reading:

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Regardless of this value, you will always get a couple of core fields returned with your dataset that are not in your ViewFields. IncludeMandatoryField expands it to include things like fields flagged as required, dependent fields for calculated and computed columns, and some additional metadata fields that are normally hidden from the UI.

share|improve this answer
    
Ok, so no matter what the value some "core fields" will always be returned. What determines if a field is a "core field"? –  Kit Menke Jun 20 '11 at 0:53
    
It coded somewhere in the depths... you can't change it. In the past when writing some custom web services I filtered it out of the result returned to the client manually. –  Chris Beckett Jun 20 '11 at 4:16
    
@KitMenke can it be defined in core content-type? I found only 2 fields in Item content-type, but when you create a new View from SP admin page, there is 15 available. Where did they get it? –  surlac Dec 20 '12 at 6:51
    
Content types are templates for content and have to be associated with a list or library to use. Those extra fields such as created by and modified by are not on the content types, they system fields that are part of lists and libraries. No, you can't add those columns to the core content type. –  Chris Beckett Jan 18 '13 at 3:59
add comment

I believe it's a bug. It does however bring in the fields you specify in ViewFields first. So you could potentially do a workaround that only returns the first X columns, where X is the number of ViewFields specified.

share|improve this answer
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.