#community-help

Filtering by Boolean in JS SDK

TLDR Gustavo had trouble filtering by boolean in JS SDK. Kishore Nallan suggested using 'bool' instead of 'boolean', which resolved the issue.

Powered by Struct AI
10
6mo
Solved
Join the chat
Jun 04, 2023 (6 months ago)
Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
07:29 PM
Hey, I'm having trouble to filter by a boolean. I'm using the JS SDK and I've already tried filter_by: 'blocked:=true' , filter_by: 'blocked=true' , filter_by: 'blocked:true' , filter_by: 'blocked' , and none of them worked. Why?
07:33
Gustavo
07:33 PM
Also tried in the web console.
Image 1 for Also tried in the web console.
Jun 05, 2023 (6 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:44 PM
Can you please tell me what error you are getting when you do so?
Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
01:54 PM
Yes, give me a few minutes
02:06
Gustavo
02:06 PM
Here's the schema:
Image 1 for Here's the schema:
02:08
Gustavo
02:08 PM
The error message:
> RequestMalformed: Request failed with HTTP code 400 | Server said: Error with filter field blocked: Unidentified field data type, see docs for supported data types.
02:10
Gustavo
02:10 PM
The code:
Image 1 for The code:
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:15 PM
It must be 'bool' not boolean
Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
02:19 PM
Oh, it works now. Consider implementing some validation to show an error message when someone tries to set a type that doesn't exist in the schema. Thank you.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:29 PM
Will do.