For each loop, to create items in a separate database
Hi!
I'm importing information from a JSON object, and I want to be able to take an array of tags, and add them to a separate database. For example,
I'm trying to import each individual item from the "types" array into a separate database called tags. I'd like to have them as individual tags that I can later reference and filter by.
So far, I've been able to import all the other information, but when I try to add the types using a For Each Loop, I keep getting the following error:
Here's my current function stack. I've tried so many things, like:
- establishing a variable with an empty array inside and outside of my For Each loop that I've tried to merge the array with, but with no success.
- bulk add records, both inside and outside of the for each loop.
I feel like the solution is simple, but I'm missing something here… Can I please get some assistance?
Answers
-
Hi,
it looks like the field in which you want to save your tag, restaurant in that case is set to be an integer and it is throwing error because you are trying to pass a string.
-
Thanks Pawel. That is exactly what the error messag is returning. However, here's how I have my data mapped in the for each loop. The "id" field is hidden, so that it should be automatically incrementing. I have the variable "tag" set to input on the input field, "tags". Any other suggestions?
-
Ok, that's interesting. Is it working when you use some other value than tag to add the record?
-
Yes, that's exactly what I figured out today!
What I ended up doing was creating a new variable within the For Each loop, and set it equal to tags. Then, using that variable, I was able to input the information needed into my database.
Note to anyone else having trouble - try using a variable as a middleman in your process! Worked for me, and it seems to have worked for a couple other people on here too :)
Thank you for your response Pawel!
Sample screenshot of my working function stack here:
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