6

I'm using SPSiteDataQuery class to query pages for particular content type and tag across the site collection. The custom content type is inherited from Page content type and contains 'Summary' field of HTML type.

The problem is that some rows in the query results have empty summaries ​​in spite of the fact that summary field is required and values are specified for all list items. The weird thing that if I remove tag filtering from query then summaries for all items are returned by SPSiteDataQuery.

Field declaration:

<Field ID="{76F58F2C-8574-48DB-B539-7EC26BDB46F5}"
       Name="ArticleSummary"
       Group="Custom"
       DisplayName="Summary"
       Type="HTML"
       Required="TRUE"
       RichText="TRUE"
       RichTextMode="FullHtml" />

Query:

<Where>
  <And>
    <BeginsWith>
      <FieldRef Name=ContentTypeId' />
      <Value Type='Text'>0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900fbd29e8cfdd742e9bb524da6f26152ad<Value>
    </BeginsWith>
    <In>
      <FieldRef Name='TaxKeyword' LookupId='TRUE'/>
      <Values>
        <Value Type='Counter'>20</Value>
      </Values>
    </In>
  </And>
</Where>

Code:

SPSiteDataQuery query = new SPSiteDataQuery();
query.ViewFields = "<FieldRef Name='Title' Type='Text'/><FieldRef Name='ArticleSummary' Type='HTML'/>";
query.Lists = "<Lists ServerTemplate='850' />";
query.RowLimit = 100;
query.Webs = "<Webs Scope='SiteCollection' />";
query.Query = "...see above...";

DataTable results = web.GetSiteData(query);
1

What you need is basically to point in the ViewFields of the Query that you field could be Nullable at times by using <FieldRef Name='{0}' Type='{1}' Nullable='TRUE'/> replace {0} with field name and {1} could be TEXT or NOTE.

Your Answer

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

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