I'm using SPServices and unslider.js to display a slideshow on a page. Instead of showing all items in the slider, the requirement is to manage the slides by using a filtered view. I added tags but I don't know caml and how to specify the view required.

jQuery(document).ready(function($) {
      var sliderList = "Slider"; // Name of the list that contains slides
      var slideContentField = "HTML"; //Name of the Rich text field that has slide content
      var slideBackgroundImageField = "Picture"; //Name of the picture field to use as background image
 function HillbillySlider(sliderList,slideContentField,slideBackgroundImageField) {
     //query to retrieve all items
     var query = "<View><Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq></Where></Query></View>";
     //return fields for slide content and background picture
     var camlViewFields = "<ViewFields><FieldRef Name='"+slideContentField+"' /><FieldRef Name='"+slideBackgroundImageField+"' /></ViewFields>";
          operation: "GetListItems",
          async: true,
          listName: sliderList,
          CAMLViewFields: camlViewFields,
          CAMLQuery: query,
          completefunc: function(xData, Status) {
               $(xData.responseXML).SPFilterNode("z:row").each(function() {
               var slideContent = ($(this).attr("ows_"+slideContentField));
               var picture = $(this).attr("ows_"+slideBackgroundImageField)==undefined?"":$(this).attr("ows_"+slideBackgroundImageField).split(",")[0];
               //create slide (li) and append it to other slides
               $("#hillbillySlider").append("<li style=\"background-image: url('"+picture +"');\">"+slideContent+"</li>");
          }); // end completefunc
          //start the slider
     }); // end SPServices call
  • so this returns no items? Oct 8, 2014 at 20:53
  • It returns ALL the items - that's the problem. In my answer I clarify how I was able to filter the items.
    – matt
    Oct 9, 2014 at 0:28

2 Answers 2


Looks good, but you need to query on an ID if that's the parm you have. Also, remove the <View> tag from your query:

<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>" + id + "</Value></Neq></Where></Query>

This will return all Items except the one with that ID. I'm not sure that you even need the CAMLViewFields argument unless you only want those two fields returned

  • Thanks - I was doing it all wrong and got it figured out.
    – matt
    Oct 8, 2014 at 23:49
  • Np. +1 if I helped ;) Oct 9, 2014 at 0:02

I was approaching it the wrong way. Through force of habit, I was trying to get the list view involved to do the filtering, but I realized I can "roll my own view" and filter directly in the query with:

<Query><Where><And><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq><Eq><FieldRef Name='Active0' /><Value Type='Boolean'>1</Value></Eq></And></Where></Query>

So only items that have a "yes" value in a yes/no field show up.

Your Answer

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

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