Appending Record to Array

Options
I'm having some trouble appending a new record to an existing array. So far the only thing I've been able to achieve is overwriting whatever array is already in place.

The basic logic I am trying to achieve here is that I have a table TEAM and I'm trying to add USERS to that table, pretty straight forward, but I haven't been able to get this thing working despite my best efforts.

Here is the API I've setup to do this, any idea what I'm doing wrong?

[image.png]

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    It looks like you are appending the array to itself instead of a new element to the array.

    I don't see a screenshot of what it looks like when you click on the array but it should resemble something like this. https://docs.xano.com/working-with-data/functions/data-manipulation/arrays#add-to-end-of-array
  • Patopt
    Patopt Member
    Options
    I'm trying to follow that, but still getting some odd behavior. I'm majorly stuck, but just feel like I'm likely missing something simple here...

    I tried to simplify my function stack some, here is some more detail with all of the output from running this.

    Step 1 - Populate the array with what already exists.

    [image.png]
    Step 2 - Add users_id which is a reference field to another table to the end of the array.

    [image.png]
    Step 3: Input the changed array back into the users_id reference column in the teams table.

    [image.png]Here is me trying to populate 1,2,3 into the array.
    [image.png][image.png]
    [image.png][image.png][image.png][image.png]