none
Query override - Content query web part

    Question

  • Hi All,

    I am working on the CQWP in MOSS 2007. I have to display the contents of docuemnt libraries based on more than one content type of it. But bydefault the CQWP  allows to use only one content type. I got a piece of code from an article to customize the "QueryOverride" property of the CQWP by exporting it to a  local drive and editing it.

     

    In my Document library i have two content types namely-Proposal,Document

    Proposal - Our own custom site content type.

    Document - default site content type.

     

    I have changed the "QueryOverride" property as below based on the code which i got from that article.

     

    <property name="QueryOverride" type="string">

    <![CDATA[

    <Where><Or>

    <Eq><FieldRef Name="ContentType"/><Value Type="Text">Proposal</Value></Eq>

    <Eq><FieldRef Name="ContentType"/><Value Type="Text">Document</Value></Eq>

    </Or></Where>

    ]]>

    </property>

     

    But, when i run my site after importing the web part, got an error as below,

    "There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again."

     

    Anyone been able to do this successfully?  Have an example?  Other ideas?

     

    Thanks in advance.

     

     

     

    Thursday, January 17, 2008 6:35 AM

Answers

All replies

  • Maybe this post will help you: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1509871&SiteID=17. The author said that the problems are in the Carriage Returns so removing them solves the problem.

    Friday, January 18, 2008 6:13 AM
  • Thanks Waldek. I solved it. There was a carriage return in my query.

     

    • Proposed as answer by Dilli.Babu Thursday, August 06, 2009 5:10 AM
    Wednesday, January 23, 2008 8:04 AM
  • Hi All,

    I have this query written to get additional filter fields in CQWP but, when i use this i get an error "There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again."

            

    <property name="QueryOverride" type="string">
              <![CDATA[
    <Where><Or>

     <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Wake</Value></Eq>
     <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Pain</Value></Eq>
     <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Pain</Value></Eq>
     <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Pain</Value></Eq></Or></Where>

              ]]>
           </property>

    can anyone help me with to solve this problem.

    Thanks in advance.

    Thursday, May 24, 2012 7:31 PM
  • The <Or> statement only accepts two arguments. Thus, you need to create child <Or>s like this:

    <Where>

    <Or>
      <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Wake</Value></Eq>
      <Or>
        <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Pain</Value></Eq>
        <Or>
            <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Pain</Value></Eq>
            <Eq><FieldRef Name='Departments'/><Value Type='Text'>CNS-Pain</Value></Eq>
        </Or>
      </Or>
    </Or>

     </Where>

    Tuesday, November 13, 2012 11:27 AM