This project has moved and is read-only. For the latest updates, please go here.

Help CAML where clause not working in SPServices

May 22, 2013 at 11:26 AM
Edited May 22, 2013 at 11:27 AM
Here is the code I can't filter the results using my CAML query. I don't know what's the problem. I'm using jquery 1.8.2 and SPServices 0.7.0

$(document).ready(function ()
    var s = $().SPServices.SPGetCurrentUser();
function get_user(users)
    var query = "<Query><Where><Eq><FieldRef Name='Assigned'/><Value Type='Text'>" + users + "</Value></Eq></Where></Query>";
        operation: "GetListItems",
        async: false,
        listName: "Users_List",
        CAMLViewFields: "<ViewFields><FieldRef Name='Assigned' /><FieldRef Name='Users_Number' /><FieldRef Name='Users_Name' /></ViewFields>",
        CAMLquery: query,
        completefunc: function (xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function () {
                var s = ($(this).attr("ows_Users_Name"));
May 22, 2013 at 12:26 PM
It's going to depend on what type of column Assigned is in your list Users_List. You're passing the user's account as a string.

May 22, 2013 at 12:36 PM
the Assigned column is a text sir
May 22, 2013 at 2:12 PM
And are those text values account names, like "domain/account"?

May 23, 2013 at 2:59 AM
yes sir
May 23, 2013 at 3:15 AM
Try changing the match type from Eq to Contains. My assumption is that (since the field is of text type) there is something else stored with the value that you can't see (ex. A trailing space).
I assume that you have confirmed that you have at least one row with data that matches what you are filtering on - for testing purposes.

Sent from mobile device.
May 23, 2013 at 4:04 AM
I already tried sir but it's still displaying all the data
May 23, 2013 at 4:44 AM
Edited May 23, 2013 at 4:46 AM
Thanks guys i solved my problem it's just a typo error hehe I type CAMLquery instead of CAMLQuery and I forgot that the assigned column has backslash so I need to escape that using double backslash