0

I am trying to make a filter with REST, the code executes only the first part of the filter, here's my query:

http://site/_api/web/lists/getByTitle('Data')/items?$orderby Created desc&$filter=(Category eq 'Students') and (Registered ne null)

However, it's getting all Students, whether registered or not. any help is appreciated.

Registered column is single line of text.

  • Did you try '' instead of null – Monica Jagani Dec 16 '16 at 6:31
  • Correct, An empty Single Line of Text is an empty string, not null – Danny '365CSI' Engelman Dec 16 '16 at 9:23
  • @Danny'365CSI'Engelman, if you check the value of the column returned by sharepoint in developer tools, it will be null, not an empty string. – Jacky Dec 16 '16 at 17:52
  • @MonicaJagani, please check my comment above. – Jacky Dec 16 '16 at 17:52
  • I tried the multiple $filter, works fine on a standard Tasks list with empty DueDates... but.. thats a Date field.. not a text field; but also returns null in the REST response – Danny '365CSI' Engelman Dec 16 '16 at 18:07
1

I don't think you can do it by checking null values, you can do it by getting items where the column is gt 0, so your query would be like:

http://site/_api/web/lists/getByTitle('Data')/items?$orderby Created desc&$filter=(Category eq 'Students') and (Registered gt 0)

This will check the length of the string added to the column, in this case > 0 would mean ne null.

  • it worked :) so with text fields i can not use null? – Jacky Dec 16 '16 at 18:11
  • that's correct. – Mohamed Derhalli Dec 16 '16 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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