When I perform a REST query to the following URL:
_api/web/lists/getbytitle('BtProjects')/items?$filter=Active eq true
I receive only the one item that has this field marked as false
. I get the same result when regarless of whete I use eq true
or eq false
. Anyone have any suggestions for a work-around? This is on prem SP1 and my understanding is that this issue does not appear on SP Online, but I've not verified that.
4 Answers
Try using 1 for true, 0 for false. I was able to replicate your problem in SPO, but using 1/0 worked fine:
/_api/web/lists/getbytitle('BtProjects')/items?$filter=Active eq 1
-
-
I was trying with 'true' & 'yes', but didn't thought about 1/0. This did the job, well done! Oct 11, 2017 at 9:20
I thought I had already tried Active ne false
but I guess I had not. That seems to work. It looks like the eq
filter is broken for booleans, though.
-
This solution works better when existing items may not have a value for the field. Not relative to the question, but a good thing to know.– jbeankyNov 29, 2016 at 12:11
-
-
Booleans are still broken when using SharePoint Online and the REST API. As of this writing, using 1/0 and true/false do not function as expected. When I tested, it actually returned the FULL dataset and ignored my $filter parameter.
Instead, I just created a choice column (with yes/no as options) and switched to that:
/_api/web/lists/getbytitle('BtProjects')/items?$filter=Active eq 'Yes'
I was able to get this to work using the methods described by wjervis and Robert recommended, but only when the bool field was the first filter term like below. Another thing to note is that the bool field can be null although the odata readout may show a true or false for the field.
/_api/ProjectData/Resources()?$filter=checkBool eq true & ResourceEmailAddress ne null
field eq true
orfield eq 'true'
returns items where field is false.