array as input
Hi all, I am in trouble using array as input in my stack.
In my case I have a "insured" table and a "policy" table. I am using filter by a custom query WHERE db:policy.id = var_2.id (var_2 is a list of policy id, resulting from customer relationship and auth control). I tried to pass this list and got this error
{
message:
ParseError: "policy.id" = [26,24], message=Lists are not supported.
}
but how to execute a search loop to each id until end of loop?
I have read question https://community.xano.com/discusion/1924451/how-to-use-an-array-of-objects-as-a-function-input but the answer is not clear for me.
help please :)
Best Answer
-
Hey @thierry, based on your screenshot above, I would again recommend the IN operator. IN asks whether "A" is in ["A", "B", "C"]. So when the first argument is an int or a string, and the second argument is an array of same, you want to use IN.
Answers
-
You want to use the "IN" operator for this job. = will test whether "A" is "A". IN will test whether "A" is part of ["A", "B"].
-
IN operator will returns for selected value only. So, do you mean to add this inside a loop ?
-
If both are lists then you will want to use the OVERLAPS operator. IN is used to evaluate a single value "in" a list.
-
Hi Michael, thank you for this. Could you show us how to apply this ?
-
@thierry no problem, this is accessible in the by custom query section of query all records:
You can also use CONTAINS to accomplish the same thing:
-
Hi Mickael, thank you for this tutorial. Easy to follow, but when I passing two existing id in my input list I stills get this error:
{
message:
ParseError: "insured.id" contains [19,21], message=1st operand must be json or an array.
}
//19 and 21 are db table existing reference ids.
// my "inputlist" is Type: integer and structure: list selected.
I saw I have the integer [] in red alert ?
any idea ?
-
Hi Ray, thank you to both of you It' s ok this way.
OVERLAP returns the same Type error than with =
message is: "Input requires integer. Currently set to integer[]."
but with a IN operator I got the result I looking for.
Have a nice day :)
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback