Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
you said you wraped your code in CDATA but I cant see that :S –  yuri kilochek Aug 30 '12 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 :)

share|improve this answer
    
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 '12 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 ? –  yuri kilochek Aug 30 '12 at 16:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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