1

I'm having trouble with ViewFieldOverrides in CQWP. I'm showing a CQWP that rolls up Discussion Items and the Site they belong to.

I can get my needed properties using @LinkUrl and "URL" as the slot. Then I get the ProjectProperty.Title for the title of the site they belong to. For the Site Title, I use ViewFieldOverride.

My problem is, it kinda broke the @LinkUrl? If I remove the ViewFieldOverride, it works. But the other one doesn't.

How can I get it to work for both?

I tried something like this but it did not work:

<property name="ViewFieldsOverride" type="string">
    <FieldRef Name="URL" Nullable="True" Type="URL"/>
    <FieldRef Name="PublishedLinksURL" Nullable="True" Type="URL"/>
    <ProjectProperty Name="Title" />
</property>
0

When ContentByQueryWebPart.ViewFieldsOverride property is specified, it overrides default list field names used to filter the set of list items. It means all the required fields have to be specified explicitly, in your case it would be:

 <property name="ViewFieldsOverride" type="string"><![CDATA[<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Nullable="True" Type="Text" /><FieldRef ID="{94f89715-e097-4e8b-ba79-ea02aa8b7adb}" Nullable="True" Type="Lookup" /><ProjectProperty Name="Title" />]]></property>

where Field IDs

fa564e0f-0c70-4ab9-b863-0177e6ddd247: Title 
94f89715-e097-4e8b-ba79-ea02aa8b7adb: FileRef

Manifest example: aggregating Discussion items

<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">Discussions</property>
        <property name="SortByDirection" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+SortDirection, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Desc</property>
        <property name="ContentTypeBeginsWithId" type="string">0x012002</property>
        <property name="SortBy" type="string">{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}</property>
        <property name="WebUrl" type="string"></property>
        <property name="ServerTemplate" type="string">108</property>
        <property name="DataMappingViewFields" type="string">{b9e6f3ae-5632-4b13-b636-9d1a2bd67120},Computed;{543bc2cf-1f30-488e-8f25-6fe3b689d9ac},Image;{fa564e0f-0c70-4ab9-b863-0177e6ddd247},Text;</property>
        <property name="ViewFieldsOverride" type="string"><![CDATA[<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Nullable="True" Type="Text" /><FieldRef ID="{94f89715-e097-4e8b-ba79-ea02aa8b7adb}" Nullable="True" Type="Lookup" /><ProjectProperty Name="Title" />]]></property>
      </properties>
    </data>
  </webPart>
</webParts>

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.