Skip Ribbon Commands
Skip to main content

:

> Posts > Simple CAML Query Tester using jQuery & SPServices
February 10
Simple CAML Query Tester using jQuery & SPServices

So, I can either sound like I'm the nicest guy in the world and say I threw together a little script to make your life easier when testing your CAML queries, or I can be honest and say I'm tired of people saying my scripts don't work because they don't know how to write CAML queries…hmmm.. Which to choose... Which to choose…

Regardless, one of the biggest problems when using SharePoint's Web Services, The Client Object Model, or SPServices is tracking down problems in your scripts. Sometimes it's hard to know if your CAML query is wrong or if it's something else in your script. How do you even know if your CAML query is returning the right information??

Well, to help you out I created the very simple script that you can download here. I even made the links to jQuery and SPServices external so all you have to do is drop this puppy in to do you testing. Please note, this script is NOT meant to help you *build* your queries. There are other tools for that. This is purely a testing tool to help you during those "doh" moments.

The script works as follows:

  1. Input your target list name
  2. Input the desired View Fields (using the correct syntax)
  3. Input your CAML query (using the correct syntax)
  4. Press the "Execute Query" button.

Your results will be displayed in a table next to the "Query Results" label. If an error occurs it will also be displayed in the Query Results table. Once you have your query written correctly, you can just copy it out of the text box and past it into your solution.

The script also comes with some default information entered into the text boxes so you can get used to the basic syntax of the queries. You can see a live demo of the script here.

That's it! Short and sweet… now go enjoy your weekend.

Comments

Genius

You, sir are a bloody genius.  Thanks for the script, it's great for a beginner.  Just popped it into my sp and boom, win.  Now I can use it to figure out the crap I was doing wrong before.
 on 5/4/2012 9:53 AM

Thanks!

Helped me find an error that a field had not been installed correctly. Till then I was looking in all the wrong places.
 on 8/31/2012 9:38 AM

SharePoint Architect, Developer, Blogger, Speaker, Author, and general pain in the butt.
 
Thoughts, views, and opinions expressed in this blog are solely my own.
 
Remember, the Impossible just takes longer.
​​​​
 

 Blogs you should be reading