Table ChangesetArray Not working for me

I'm very new to database building/sql and i'm trying to get the changesetarray to work for a table I have.

I have a table with data that I want to be able to be updated if someone makes a spelling mistake, needs to update the contact info, etc for my vendors.

I made a query with the GUI for bulk update via primary key and I keep getting the error: "Data must be an array"

1 Like

Hi there @MIdzerda and welcome to the forum!

So the variables are case sensitive, and it seems your table is Vendor_Table with caps, so that may be the reason why your query gets that error, as is returning undefined. Can you give it a try with Vendor_Table.changesetArray?

I tried that and it gave me this error:

query4 failed (0.003s):Unable to access 'Vendor_Table' since it is scoped to 'vendors'. 'query4' is scoped to the app.

query4

from query4 response(query4)

in query4.trigger()(query4)

additionalScope: undefinedtriggeredById: "Vendor_Table"environment: "production"

in Vendor_Table save event handler(Vendor_Table)

from user interaction

1 Like


Here's what the Vendor_Table looks like in the inspector, if that helps.

1 Like

Hi @MIdzerda , welcome to the community. Well, is this table on a specific page? If so, could you move query4 to the same page and try again? Thanks!

1 Like

HI @MIdzerda,

To echo @Marcus_Santos, there seems to be a scope issue between your table and your query. You can find a bit more documentation on Global and Local Scope here Retool apps tutorial: Configure multiple pages | Retool Docs

See a similar issue solved also here

I moved everything to the same page and tried again and it is still giving the same error. "Data must be an array".

Hi @MIdzerda,

Glad to hear the scoping error is gone. The "Data must be an array" should be straightforward to solve.

I am somewhat surprised that the data from the MySQL query to vendor_table needs to be formatted but you can add in a transformer to the query to add [] around the data and it will then be an array.

Should that be for the query that fills in the table data or the query that runs the changesetarray?

If I change it for the table data then the table displays as an array in each column:

the other weird thing is the "array of records to update" shows that it is undefined when I use the {{ vendor_table.changesetArray}} :

I'm not exactly sure how I got it to work but I fixed it lol So it's working properly now.

2 Likes

In my example where I had data that was not in an array for the table component to iterate through, I added the [ ] to the query that fills in the table.

This is the same query that runs on success after the update query runs that uses the data from the changeSetArray.

I am glad to hear you got things working!

I am confused as to why adding the [ ] to the transform results caused that :thinking:

If every item in the columns is getting turned into an array, that is occurring at a level lower down into the data, and the purpose of wrapping all the data with [ ] was to do so at the top level.

If you can share the table query, the updating the DB query and the event actions that could be very helpful for future users!

Hi @MIdzerda,

I know you mentioned you were note exactly sure how but that you managed to get this working on your end. If you care to share any screen shots that you think would be helpful to any other users running into the same issue that would be amazingly helpful!