IN Operator - CODELESS - Searching for list of objectId's Error


In codeless, I am trying to search for a list of objectId’s using the IN operator, as soon as I add more than 1 objectID, the result is an empty list. If I run it with 1 objectID it works as expected?


When running the same query via API rest console it works fine

Result via codeless is empty list
Screenshot 2022-01-28 at 20.17.03

Try using the print block to log the value of studentObjectIds and see what it contains. The output of the print block will be in the browser console.

That contains that IDs as expected
Screenshot 2022-01-28 at 20.27.00

There are 2 things that don’t look quite right:

  1. The logic includes surrounding single quotes, while each element in the array already has quotes. As a result, the final where clause will end up looking like this:
    objectId IN (' ["value1", "value2"] ' )
  2. I suspect that even if you remove the the surrounding single quotes, it will not look right as the square brackets will break the where clause syntax

I recommend using the following block to stringify your list:
UI Builder - ConsoleDemo - Backendless 2022-01-28 14-38-21

Hope this helps.


Thanks for the Hint!.
Actually remembered I had this issue with another query few months back and had to convert the list into text, then use Regex to add the singles quotes to each objectId

1 Like

Regex is cool, but quite hard to read… Here’s a simpler version of the same logic:

it prints out:


Brilliant, Thank you