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

GetListItems: Only those items for which particular field value is not null

Oct 23, 2013 at 3:50 PM
Thanks for this wonderful tool.
I am using SPServices to query my list and I want to return only those items for which a particular field value is not null. for example
Name Id
John 001X
Kelly 002T
Harry 00LX

SPServices returns all 4 records and it returns Id field for Mark as 'Undefined'. Is there a way so that SPServices only returns only 3 records for above list?

Thanks in advance!
Oct 23, 2013 at 3:54 PM
Edited Oct 23, 2013 at 4:39 PM
Try adding a CAMLQuery like this:
CAMLQuery: "<Query><Where><Neq><FieldRef Name='Id' /><Value Type='Text'></Value></Neq></Where></Query>",
Alternatively, you can just test for the undefined value on the client side, depending on what you're trying to do.

Oct 23, 2013 at 4:37 PM
Thank you for quick response!
It seems to have some problem with <Neq>. following didn't work
"<Query><Where><Neq><FieldRef Name='Participant_x0020_ID'></FieldRef><Value Type='Text'></Value></Neq></Where></Query>",

But this worked..
"<Query><Where><IsNotNull><FieldRef Name='Participant_x0020_ID'></FieldRef></IsNotNull></Where></Query>",

Thanks again!
Oct 23, 2013 at 4:40 PM
Sorry about that. I should have tested it before I posted it. I also left out the <Where> elements (fixed above).

Oct 23, 2013 at 4:43 PM
No problem. Thanks again for sharing your great work!
Have a great day!