locked
content query with CAML for currnet user RRS feed

  • Question

  • hi,

    I am using content query web part. the requirement is "display last 7 days records of current user". am inserting CAML under "QueryOverride".
    <property name="QueryOverride" type="string" >
              <![CDATA[<Where>
              <and>
            <Geq>
                <FieldRef Name="Modified"/>
                <Value Type="DateTime">
                    <Today OffsetDays="-7"/>
                </Value>
            </Geq>
            <eq>
            <FieldRef Name="Editor" />
        <Value Type="User">[Me]</Value>
            </eq>
              </and>
        </Where>]]>
            </property>
    but am getting fallowing error any ideas ??

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

     


    Wednesday, September 21, 2011 7:38 AM

Answers

  • Hi Prashanth,

    I tested, it worked fine for me.

    You can try to delete the CQWP with the issue uploaded/imported before, and create another new custom CQWP with the code, import and check again.

    If not work, remove the special character like "returns" between <> and  <>,  and no "blank" between "<![CDATA[" and "<Where>", then check again.

    Thanks

     


    Regards, Daniel
    Thursday, September 29, 2011 7:06 AM
    Moderator

All replies

  • Hi Prashanth,

     

    You need to change the [Me] to <UserID />, refer to this article, and unify the format of <And><Geq><Eq> in the code as follow,

     

    <![CDATA[<Where>

    <And>

    <Geq><FieldRef Name="Modified"/><Value Type="DateTime"><Today OffsetDays="-7"/></Value></Geq>

    <Eq><FieldRef Name="Editor" /><Value Type="User"><UserID /></Value></Eq>

    </And>

    </Where>]]>

     

    Thanks


    Regards, Daniel
    • Proposed as answer by Rashu,Rahul Tuesday, September 27, 2011 6:20 PM
    Tuesday, September 27, 2011 11:09 AM
    Moderator
  • Hi Prashanth,

    If you want to always get fantastic CAML markup, consider downloading this tool. I did a few months ago and it is a life saver.

    http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx

     

    Tuesday, September 27, 2011 5:22 PM
  • hi Daniel,

    Thanks for ur repaly,

    I tried the code that u r given , but still am getting the same error ["There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again"].

    is their any to debug the query or to find what query is getting passed ?

     

     

     

    Thursday, September 29, 2011 6:48 AM
  • Hi Prashanth,

    I tested, it worked fine for me.

    You can try to delete the CQWP with the issue uploaded/imported before, and create another new custom CQWP with the code, import and check again.

    If not work, remove the special character like "returns" between <> and  <>,  and no "blank" between "<![CDATA[" and "<Where>", then check again.

    Thanks

     


    Regards, Daniel
    Thursday, September 29, 2011 7:06 AM
    Moderator