Problem with GetListItems

Sep 9, 2010 at 9:51 PM

Hi, I'm trying to use GetListItems, but does not filter and I get all the items in the list, but I just want to get one according to a filter.

I'm using something like this:

        var valor = 5;

          $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "Gerencias Impactadas",
            CAMLQuery: "<Query><Eq><FieldRef Name='Interesados' LookupId='true'/><Value Type='Lookup'>"+valor+"</Value></Eq></Query>",
            completefunc: function (xData, Status) {
           $(xData.responseXML).find("z\\:row").each(function() {

            var num = $(this).attr("ows_Interesados");
            alert(num);
              });
            }

    });

Hopefully someone can help me out

Regards

Coordinator
Sep 10, 2010 at 3:55 AM

a_vera:

I don't see anything obviously worng. Try adding

  alert(xData.responseXML.xml);

in the completefunc to see the whole resultset. Maybe that will show you something.

Also, see this blog post for info about using the z:row namespace with other browsers:
http://sympmarc.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/

M.

Sep 10, 2010 at 3:34 PM

Problem solved, I use that line of code.

CAMLQuery: "<Query><Where><Eq><FieldRef Name='"+item +"' LookupId='True'/><Value Type='"+tipo+"'>"+valor+"</Value></Eq></Where></Query>",

Regards;

Coordinator
Sep 10, 2010 at 4:46 PM

Ah! You were missing the <Where> clause. Sorry I missed that; doing too many things at once.

Glad you got it working!

M.