I have the following CAML query which returns checked out files.

<Query><Where><Eq><FieldRef Name="CheckoutUser" /><Value Type="User">[Me]</Value></Eq></Where></Query>

I want to use this in a Content Query web part, within the 'QueryOverride' section.

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

I'm new to this, but believe it can be done. Can someone convert this for me please or point me in the right direction.

All help appreciated.

  • you said you wraped your code in CDATA but I cant see that :S
    – Learner
    Aug 30, 2012 at 16:14

1 Answer 1


Follow these steps;

  1. Place the standard CQWP onto the page.
  2. Export the web part (in the web part pane, click edit -> Export and save the file to your PC)
  3. Open the webpart you just exported in Notepad or some other plain text editor
  4. Find the property
  5. Embed your CAML query into a CDATA section, the above query will now look like this;

< ![CDATA[ < Where > < Eq >< FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"> < /FieldRef > < Value Type="Number">3< /Value>< /Eq>< /Where>]]>

  1. Place this CAML into the QueryOverride property in the webpart. That line of markup should now look like this;

< property name="QueryOverride" type="string" > < ![CDATA[< Where>< Eq>< FieldRef ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}" >< /FieldRef

< Value Type="Number" > 3< /Value>< /Eq >< /Where >]] > < /property >

  1. Save the webpart text
  2. Import the webpart back into Sharepoint. Click ‘Add a Web Part’ in the web part zone of the page ->Advanced web part gallery and options -> Browse -> Import. Select your modified .webpart file that you saved to your PC.
  3. An icon for your webpart will appear in Sharepoint. Drag that into the webpart zone you want this to appear in.

Check in your page, and see the results.

Taken from : Using CAML in CQWP

Hope it helped :)

  • Thanks, yup thats helped! I can import the webpart now which was my original question, my issue now is the webpart isnt producing the same results as the CAML query did.
    – Justin
    Aug 30, 2012 at 16:29
  • so basically when yu tested yur CAML query outside webpart it gives some results but if you test it within webpart it gives you different results, if thats true ?
    – Learner
    Aug 30, 2012 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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