For each loop, to create items in a separate database

Options

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?

Tagged:

Answers

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    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.

  • TimSek
    TimSek Member
    Options

    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?

  • Pawel Magdanski
    Pawel Magdanski Member ✭✭✭
    Options

    Ok, that's interesting. Is it working when you use some other value than tag to add the record?

  • TimSek
    TimSek Member
    Options

    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: