??‍♂️ Object Array being Deleted instead of Added to

Options

I have a table for users and a column (object data type) for profiles. The profile schema is very simple: profile_id, profile_firstname, and profile_lastname.

I have an endpoint that takes a new profile firstname and lastname. It finds the last profile on the user and pops off the profile_id, adds one to "autoincrement". Everything is working except the Add Record step.

I have tested filters for the profiles column to be: merge, append, and set. Yet none of these are simply adding the values to this object array as I need. Instead, the existing values are deleted and the new values never show up.

Here is a Loom video showing how the API function is actually deleting any previous records and not storing the new values. https://www.loom.com/share/d109b418c543403ca613d63afb200697?sid=97ab89e3-edc3-4e14-be81-de5cf00c1c78

I appreciate any guidance here!!

Tagged:

Answers

  • arturosanz
    arturosanz Member ✭✭
    Options

    I would try to isolate the problem by calculating and saving in a variable the profile object list prior to the Add or Edit Record function. Then, inside the Add or Edit Record function, you just map the profile field to the previously calculated variable with the list of objects without filters.

    If you do so, you will have access to the variable contents in the debug mode, and you will know whether there is a problem with the Add or Edit Record function or with the filters to construct the object list.

  • joefromkansas
    Options

    Thanks for replying! I'll give that a go and create a new variable that I can ensure is formatted properly. I'll let you know if that works either way!

  • Lefteris - blupry.com
    Options

    Hi @joefromkansas,

    So, I noticed two things you are probably doing wrong.

    Firstly you are not adding a record there, it is still a field of another record (despite it looking like a table), so you should just edit it.

    Secondly, on the edit record you should give as initial value the one you get from the get record, and then proceed to append another item. Specifically,

    here you should have it equal to Profiles_1.profiles (tailored for the example on the video).

    Hope that helps!

  • joefromkansas
    Options

    Thank you for the feedback. I solved this by simplifying each step and then using the Add Record function at the end.

    There's like a better way to do this, but I simply copy all existing data in the array, prepare the new object, then "add them together" by appending the new object. Then I use that final combined array as a simple input for the Add Record.

    Here's the Loom video showing the final run through. I wish I could have gotten the Add Record method to work, but I couldn't figure it out. This seems safe enough though for my use case since my users will likely only have 8-10 profiles (records) in this array at most.

    https://www.loom.com/share/c603b29cb2fc49469716f7c62ba062ce?sid=8d2096a2-c919-46d6-ace3-c1f549a7556c

  • Lefteris - blupry.com
    Options

    Hey @joefromkansas,

    I guess my answer wasn't really clear.

    There is no way you can use the Add record for this, simply because you are not actually adding a record.

    In your case you are just changing the value of an existing record's field (The profiles field that happens to look like a table, yet it is not treated as one inside xano).

    Hope that clears it up.

    Your implementation is not wrong at all. Only downside could be that in case someone has many records, the API would take a little bit more time to finish, but as you said that is not likely to happen.